Preview: these APIs are still being designed and aren't available yet.
Skip to Content
UpskyDocs
API reference

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.

POST
/v1/ai/chat/completions

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.

Authorization

apiKey
headerAuthorizationBearer <token>

Your API key, starting with upsky_test_ or upsky_live_.

Request Body

application/json
  1. 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*string

A model ID from GET /v1/ai/models.

Length1 <= length <= 200
messages*array<>
Items1 <= items
stream?boolean

Send the reply as server-sent events as it's written. The last event before [DONE] reports usage and cost.

max_completion_tokens?integer

The longest reply to allow, in tokens. Without it, a team without auto top-up may get a lower limit that its credits cover.

Range0 < value
max_tokens?integer

Older name for max_completion_tokens.

Range0 < value
temperature?number
tools?array<>

Function tools. Other tool types are refused.

n?integer

Only 1 is supported.

[key: string]?unknown

Response Body

The model's reply, or with stream: true a stream of chat.completion.chunk events.

  1. response
id*string
object*"chat.completion"
Value in"chat.completion"
created*integer
model*string
choices*array<>
usage*
[key: string]?unknown
Example Request
curl -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}'
Example Response
{  "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}