Another language?
Return the model's whole reply as message, including tool_calls:
{ "message": { "role": "assistant", "content": "...", "tool_calls": [ ... ] } }
When the request has stream: true, return the provider's text/event-stream
unchanged. On an error, include the status so Code Chat can wait and retry:
{ "error": "Request failed with status code 429", "status": 429, "retryAfter": 20 }
An image request arrives with imageModel and prompt instead of messages.
Send it to the provider's image API, save the image, and return its URL:
{ "url": "uploads/ai-a1b2c.jpg" }