Create a chat completion
Sends messages to a model and returns its reply, in OpenAI's Chat Completions format. With a test key the reply is canned and nothing is charged.
Sends messages to a model and returns its reply, in OpenAI's Chat Completions format. With a test key the reply is canned and nothing is charged.
apiKeyAuthorizationBearer <token>Your API key, starting with upsky_test_ or upsky_live_.
application/json- body
OpenAI's Chat Completions format. Fields not listed here are passed to the model as sent, except providerOptions other than gateway.order, gateway.only and gateway.sort, and user, which are dropped.
model*stringA model ID from GET /v1/ai/models.
1 <= length <= 200messages*array<>1 <= itemsstream?booleanSend the reply as server-sent events as it's written. The last event before [DONE] reports usage and cost.
max_completion_tokens?integerThe longest reply to allow, in tokens. Without it, a team without auto top-up may get a lower limit that its credits cover.
0 < valuemax_tokens?integerOlder name for max_completion_tokens.
0 < valuetemperature?numbertools?array<>Function tools. Other tool types are refused.
n?integerOnly 1 is supported.
[key: string]?unknownThe model's reply, or with stream: true a stream of chat.completion.chunk events.
- response
id*stringobject*"chat.completion""chat.completion"created*integermodel*stringchoices*array<>usage*[key: string]?unknowncurl -X POST 'https://api.upsky.dev/v1/ai/chat/completions' \ -H 'Content-Type: application/json' \ -d '{ "model": "string", "messages": [ { "role": "string", "property1": null, "property2": null } ], "property1": null, "property2": null}'{ "id": "string", "object": "chat.completion", "created": 0, "model": "string", "choices": [ { "index": 0, "message": { "role": "string", "content": "string", "property1": null, "property2": null }, "finish_reason": "string", "property1": null, "property2": null } ], "usage": { "prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0, "cost": 0, "property1": null, "property2": null }, "property1": null, "property2": null}