Criar chat completion
post/v1/chat/completions
Cria uma resposta do modelo a partir de um histórico de conversa. Respostas em streaming e sem streaming são suportadas.
Compatível com a API Chat Completions da OpenAI.
Autenticação
Envie sua chave de API da OLETOKEN como token Bearer. As chaves são criadas na página Chaves de API do console.
Authorization: Bearer $OLETOKEN_API_KEYCorpo da requisição
Content-Type:application/json
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| model | string | ID do modelo | |
| messages | Message[] | As mensagens da conversa | |
| role | stringsystemuserassistanttooldeveloper | Papel da mensagem | |
| content | string | MessageContent[] | Conteúdo da mensagem | |
| type | stringtextimage_urlinput_audiofilevideo_url | — | — |
| text | string | — | — |
| image_url | object | — | — |
| url | string | — | URL da imagem ou dados em base64 |
| detail | stringlowhighauto | — | — |
| input_audio | object | — | — |
| data | string | — | Dados de áudio codificados em Base64 |
| format | stringwavmp3 | — | — |
| file | object | — | — |
| filename | string | — | — |
| file_data | string | — | — |
| file_id | string | — | — |
| video_url | object | — | — |
| url | string | — | — |
| name | string | — | Nome do remetente |
| tool_calls | ToolCall[] | — | — |
| id | string | — | — |
| type | string | — | — |
| function | object | — | — |
| name | string | — | — |
| arguments | string | — | — |
| tool_call_id | string | — | ID da chamada de ferramenta (para mensagens com o papel tool) |
| reasoning_content | string | — | Conteúdo de raciocínio |
| temperature | number0–2default: 1 | — | Temperatura de amostragem |
| top_p | number0–1default: 1 | — | Parâmetro de amostragem nucleus |
| n | integer≥ 1default: 1 | — | Número de completações a gerar |
| stream | booleandefault: false | — | Define se a resposta deve ser transmitida em streaming |
| stream_options | object | — | — |
| include_usage | boolean | — | — |
| stop | string | string[] | — | Sequências de parada |
| max_tokens | integer | — | Número máximo de tokens a gerar |
| max_completion_tokens | integer | — | Número máximo de tokens de completação |
| presence_penalty | number-2–2default: 0 | — | — |
| frequency_penalty | number-2–2default: 0 | — | — |
| logit_bias | object | — | — |
| user | string | — | — |
| tools | Tool[] | — | — |
| type | string | — | — |
| function | object | — | — |
| name | string | — | — |
| description | string | — | — |
| parameters | object | — | Definições de parâmetros no formato JSON Schema |
| tool_choice | string | objectnoneautorequired | — | — |
| type | string | — | — |
| function | object | — | — |
| name | string | — | — |
| response_format | ResponseFormat | — | — |
| type | stringtextjson_objectjson_schema | — | — |
| json_schema | object | — | Definição de JSON Schema |
| seed | integer | — | — |
| reasoning_effort | stringlowmediumhigh | — | Esforço de raciocínio (para modelos que suportam raciocínio) |
| modalities | string[] | — | — |
| audio | object | — | — |
| voice | string | — | — |
| format | string | — | — |
Respostas
200Resposta criada
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| id | string | — | — |
| object | string | — | — |
| created | integer | — | — |
| model | string | — | — |
| choices | object[] | — | — |
| index | integer | — | — |
| message | Message | — | — |
| role | stringsystemuserassistanttooldeveloper | Papel da mensagem | |
| content | string | MessageContent[] | Conteúdo da mensagem | |
| type | stringtextimage_urlinput_audiofilevideo_url | — | — |
| text | string | — | — |
| image_url | object | — | — |
| url | string | — | URL da imagem ou dados em base64 |
| detail | stringlowhighauto | — | — |
| input_audio | object | — | — |
| data | string | — | Dados de áudio codificados em Base64 |
| format | stringwavmp3 | — | — |
| file | object | — | — |
| filename | string | — | — |
| file_data | string | — | — |
| file_id | string | — | — |
| video_url | object | — | — |
| url | string | — | — |
| name | string | — | Nome do remetente |
| tool_calls | ToolCall[] | — | — |
| id | string | — | — |
| type | string | — | — |
| function | object | — | — |
| name | string | — | — |
| arguments | string | — | — |
| tool_call_id | string | — | ID da chamada de ferramenta (para mensagens com o papel tool) |
| reasoning_content | string | — | Conteúdo de raciocínio |
| finish_reason | stringstoplengthtool_callscontent_filter | — | — |
| usage | Usage | — | — |
| prompt_tokens | integer | — | Número de tokens do prompt |
| completion_tokens | integer | — | Número de tokens de completação |
| total_tokens | integer | — | Número total de tokens |
| prompt_tokens_details | object | — | — |
| cached_tokens | integer | — | — |
| text_tokens | integer | — | — |
| audio_tokens | integer | — | — |
| image_tokens | integer | — | — |
| completion_tokens_details | object | — | — |
| text_tokens | integer | — | — |
| audio_tokens | integer | — | — |
| reasoning_tokens | integer | — | — |
| system_fingerprint | string | — | — |
400Parâmetros de requisição inválidos
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| error | object | — | — |
| message | string | — | Mensagem de erro |
| type | string | — | Tipo de erro |
| param | string | null | — | O parâmetro envolvido |
| code | string | null | — | Código de erro |
429Limite de requisições excedido
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| error | object | — | — |
| message | string | — | Mensagem de erro |
| type | string | — | Tipo de erro |
| param | string | null | — | O parâmetro envolvido |
| code | string | null | — | Código de erro |
Requisição de exemplo
curl -X POST 'https://api.oletoken.ai/v1/chat/completions' \
-H "Authorization: Bearer $OLETOKEN_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-4",
"messages": []
}'
