Error Types
The SDK raises specific exceptions for different error conditions:Copy
from reminix import Reminix
from reminix.errors import (
ReminixError, # Base exception
AuthenticationError, # 401 - Invalid API key
NotFoundError, # 404 - Agent not found
BadRequestError, # 400 - Invalid request
GatewayError, # 502 - Agent unreachable
TimeoutError, # 504 - Agent timeout
APIError # Other API errors
)
Basic Error Handling
Copy
from reminix import Reminix
from reminix.errors import ReminixError, AuthenticationError, NotFoundError
client = Reminix()
try:
response = client.agents.invoke("my-agent", prompt="Analyze this data")
except AuthenticationError as e:
print(f"Invalid API key: {e}")
except NotFoundError as e:
print(f"Agent not found: {e}")
except ReminixError as e:
print(f"API error: {e}")
Authentication Errors
Raised when the API key is invalid or missing:Copy
from reminix.errors import AuthenticationError
try:
client = Reminix(api_key="invalid_key")
client.project.retrieve()
except AuthenticationError as e:
print(f"Authentication failed: {e}")
print(f"Status code: {e.status_code}") # 401
Not Found Errors
Raised when the agent or deployment doesn’t exist:Copy
from reminix.errors import NotFoundError
try:
response = client.agents.invoke("nonexistent-agent", prompt="hello")
except NotFoundError as e:
print(f"Agent not found: {e}")
# "No ready deployment found for this project"
Gateway Errors
Raised when the agent machine is unreachable:Copy
from reminix.errors import GatewayError
try:
response = client.agents.invoke("my-agent", prompt="hello")
except GatewayError as e:
print(f"Agent unreachable: {e}")
# "Unable to reach agent machine. The deployment may be down."
Timeout Errors
Raised when the agent takes too long to respond (>60 seconds):Copy
from reminix.errors import TimeoutError
try:
response = client.agents.invoke("slow-agent", prompt="long operation")
except TimeoutError as e:
print(f"Agent timeout: {e}")
# "Request timeout - agent took too long to respond"
# Use streaming to avoid timeouts
for chunk in client.agents.invoke("slow-agent", prompt="...", stream=True):
print(chunk, end="")
Bad Request Errors
Raised when the request is malformed:Copy
from reminix.errors import BadRequestError
try:
# Invalid agent name
response = client.agents.invoke("invalid name!", prompt="hello")
except BadRequestError as e:
print(f"Invalid request: {e}")
# "Agent name must be URL-safe (alphanumeric, hyphens, underscores only)"
Full Example
Copy
from reminix import Reminix
from reminix.errors import (
AuthenticationError,
NotFoundError,
GatewayError,
TimeoutError,
BadRequestError,
ReminixError
)
import time
def safe_execute(client: Reminix, agent: str, retries: int = 3, **kwargs):
"""Execute an agent with retry logic and error handling."""
for attempt in range(retries):
try:
response = client.agents.invoke(agent, **kwargs)
return response["content"]
except GatewayError as e:
# Agent might be restarting, retry
if attempt < retries - 1:
print(f"Agent unreachable, retrying in {2 ** attempt}s...")
time.sleep(2 ** attempt)
continue
raise
except TimeoutError as e:
# Try streaming instead
print("Request timed out, trying streaming...")
chunks = []
for chunk in client.agents.invoke(agent, stream=True, **kwargs):
chunks.append(chunk)
return "".join(chunks)
except AuthenticationError:
raise # Don't retry auth errors
except NotFoundError:
raise # Don't retry - agent doesn't exist
except ReminixError as e:
if attempt < retries - 1:
print(f"API error, retrying: {e}")
time.sleep(2 ** attempt)
continue
raise
# Usage
client = Reminix()
try:
result = safe_execute(client, "my-agent", prompt="Analyze this data")
print(f"Result: {result}")
except AuthenticationError:
print("Check your API key")
except NotFoundError:
print("Agent doesn't exist - check the name or deploy it first")
except GatewayError:
print("Agent is down - check the deployment status")
except ReminixError as e:
print(f"Unexpected error: {e}")
Streaming Error Handling
Handle errors during streaming:Copy
try:
for chunk in client.agents.invoke("my-agent", prompt="...", stream=True):
print(chunk, end="")
except ReminixError as e:
print(f"\nStream error: {e}")
# You may have received partial content before the error