- 401 Unauthorized: API key missing or wrong. Check
.env, then runphp artisan config:clear. - 404 / model not found: Your account may not have that model. Set
OPENAI_MODELin.envto one listed in your OpenAI dashboard. - 429 Too Many Requests: Rate limit or no credit left. Wait, or add billing in the OpenAI dashboard.
- Undefined array key "content": You assumed
output[0]is a message. UseAgent::text($response), which finds the message items. - Agent repeats the same answer forever: A
returnorbreakis missing when there are no function calls. - Invalid type for output: expected a string: A tool returned a number or array. Cast it with
(string)orjson_encodeit. - Missing required parameter: tools[0]…: You sent tool objects instead of
$tool->definition(). - expected an object but got an array (text.format): You sent an empty schema. Only add
text.formatwhenschema()is not empty. - Agent forgets everything each message: The agent is created inside the
whileloop. Create it once, before the loop. - Class "App\Ai\…" not found: Check the file path matches the namespace exactly, including capital letters.
- Command hangs with no output: Tools are running inside the spinner. Wait, or watch the
Running tool:lines. - Request timed out: Long answers take time. The Agent sets
Http::timeout(120); raise it if needed.
Build an agentReference
Troubleshooting
Common errors and what they mean.
2 min readReference
