Ask a model through one of the project's routes
post/models/v1/chat/completions
Ask a model through one of the project's routes. The body and the answer follow the OpenAI chat completions format; model is a route name from the model list, never a model's own name. With stream: true the answer arrives as server-sent events. Uses the project's token allowance. The answer carries cost.usd, what the call cost; a stream carries it in a last piece when stream_options.include_usage is set. purpose is a short tag of your own that the day's usage is counted under.
Before you call
- Credential
Authorization: Bearer $KEY- Scope
models:write- Sdk
models.completion.create- Cli
models completion create
Request bodyapplication/json, required
- modelstringrequiredAt most 80 characters.
- messageslist of objectrequired
- rolestringrequiredAt most 20 characters.
- rolestringrequired
- streamboolean or null
- ninteger or null
- max_tokensinteger or null
- max_completion_tokensinteger or null
- stream_optionsobject or null
- purposestring or null
Responses
- 200text/event-streamSuccess
string - 400application/jsonThe request was malformed
- errorstringrequired
- messagestring
- 401application/jsonNo valid credential
- errorstringrequired
- messagestring
- 403application/jsonThe credential lacks the scope, origin or address
- errorstringrequired
- messagestring
- 429application/jsonOver the key's rate limit; see Retry-After
- errorstringrequired
- messagestring