Skip to main content
POST
When streaming, amber always enables stream_options.include_usage. The last chunk of the stream therefore contains the token usage. Depending on the model provider, chunks can have an empty choices list, so check that choices is not empty before accessing choices[0]. The stream ends with data: [DONE].
Errors raised by this endpoint are returned in the OpenAI error format ({"error": {"message": ..., "type": ..., "param": null, "code": ...}}):
  • 400 if the request body is not a JSON object.
  • 403 (access_denied) if AI access is not enabled for your account.
  • 404 (model_not_found) if the model does not exist or is not available to you.
  • 429 (insufficient_quota) if your API budget is exhausted.
  • 500 (type server_error, code null) if the request could not be processed.
Errors returned by the model provider (for example an invalid parameter value) are passed through with the provider’s status code and body, which does not necessarily follow the OpenAI error format above. A provider 402 is returned as 429. With "stream": true the response status is always 200: a provider error that occurs before generation starts is returned as a plain JSON body instead of server-sent events, and errors that occur during generation end the stream early. Authentication and plan errors are checked before the request reaches this endpoint and use the standard amber format {"detail": "..."} instead:
  • 401 if the Authorization header is missing (Not authenticated), or if the token is invalid, expired or not an API key / OAuth2 access token (for example Token is invalid or Token expired).
  • 403 if your tenant is on a free trial or its license plan has expired.