Agent errors through the API: agent_paused and model_not_found

All in One AIAgents Through the API·· 23 views· 3 min read

When a request to the agent fails, the API answers with an HTTP status and an error object, with code, message, correlation_id and details. The two errors caused by the agent are agent_paused and model_not_found. The others are the ones from the rest of the AI API.

409 agent_paused

The agent is paused. Turn it back on in the Agents tab of All in One AI, with Activate. The id does not change, so the program works again without changes. More in pausing, activating or deleting an agent.

404 model_not_found

The API did not find what is in model. With agents, these are the causes:

1 The id is incomplete or badly copied. It must be agent/ followed by the id, exactly as shown under Use through the API.
2 The agent belongs to another account. Each account only sees and uses its own agents, so the key must belong to the account where the agent was created.
3 The agent was deleted.

Check with GET /v1/models?type=agent: if the agent is not in that key's list, the request will not find it either. See listing your agents through the API.

The other errors

Status Code What to do
401 unauthorized The key is missing, wrong, revoked or expired. Check it or create another.
402 insufficient_credits The credits do not cover the reservation. details.required says how much is needed and details.balance how much you have. Buy credits or lower max_tokens.
403 insufficient_scope The key does not have ai:write. Create one with the right permission.
422 validation_failed A field is missing or a value is not valid. See details.
429 rate_limited You went over the requests per minute limit. Wait the seconds in Retry-After.
502 upstream_error The AI service did not respond as expected. Try again shortly.

In your code

The OpenAI SDKs read the message from error.message and raise an exception with the HTTP status. In Python it is APIStatusError:

import os
from openai import OpenAI, APIStatusError

client = OpenAI(base_url="https://api.mozout.com/v1", api_key=os.environ["MOZOUT_API_KEY"])

try:
completion = client.chat.completions.create(
model="agent/7c1e9a42-b35d8f06-a2c4e719-5d0b3f8e",
messages=[{"role": "user", "content": "Hello!"}],
max_tokens=400,
)
print(completion.choices[0].message.content)
except APIStatusError as e:
print(e.status_code, e.message)
print("Correlation ID:", e.response.headers.get("X-Correlation-ID"))

Keep the Correlation ID in your program's logs. If you contact us about a request, that is how we find it.

Want an agent that works without surprises in your program? See All in One AI.

See All in One AI

SEE ALSO

Using your AI agent through the API: agent/ in the model field

Pausing, turning back on or deleting an agent, and the agent_paused error

Listing your agents through the API: type=agent, base_model and status

API request limits: per key, per account and per task, the headers and what to do after a 429

All in One AI

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from R118.80/mo (3-year plan, with coupon)

See plans
Was this answer helpful? Your answer helps us improve this article.