cheapaimodel

Create a chat completion

Copiar
POST/v1/chat/completions

Generate the next message in a conversation with the OpenAI Chat Completions format. Set stream to receive server-sent events.

Authorization

bearerAuth
AuthorizationBearer <token>

Your API key from the console: Authorization: Bearer sk-...

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

model*string

A model ID from List models.

messages*array<>
stream?boolean
Defaultfalse
stream_options?
max_tokens?integer
Range1 <= value
max_completion_tokens?integer
Range1 <= value
temperature?number
Range0 <= value <= 2
top_p?number
Range0 <= value <= 1
stop?string|array<string>
tools?array<>

Function tools the model may call.

tool_choice?string|
response_format?

{ "type": "json_object" } or a JSON schema, on models that support it.

user?string

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

Copiar
curl -X POST "https://example.com/v1/chat/completions" \  -H "Content-Type: application/json" \  -d '{    "model": "deepseek-v4-1-flash",    "messages": [      {        "role": "user",        "content": "Hello!"      }    ]  }'
{  "id": "string",  "object": "chat.completion",  "created": 0,  "model": "string",  "choices": [    {      "index": 0,      "message": {        "role": "system",        "content": "string",        "name": "string",        "tool_calls": [          {}        ],        "tool_call_id": "string"      },      "finish_reason": "stop"    }  ],  "usage": {    "prompt_tokens": 0,    "completion_tokens": 0,    "total_tokens": 0  }}