Parámetros de la API de Completions de Chat
This document describes the request parameters for the chat completions API, used to generate responses from dialogue models.
Información de la API
- Method: POST
- Path:
/v1/chat/completions - Base URL:
https://api.uk72.cn
Autenticación
Authorization: Bearer <APIKey>Basic Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Sí | Model name, e.g., deepseek-v3 |
| messages | array | Sí | Message list |
| stream | boolean | No | Whether to enable streaming response, default false |
Message Format
| Field | Type | Description |
|---|---|---|
| role | string | Role: system, user, assistant, tool |
| content | string | Message content |
| name | string | Optional, sender name |
| tool_calls | array | Tool call list (assistant role) |
| tool_call_id | string | Tool call ID (tool role) |
Generation Control Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| max_tokens | integer | - | Maximum number of tokens to generate |
| temperature | number | 1.0 | Sampling temperature (0~2) |
| top_p | number | 1.0 | Nucleus sampling parameter |
| top_k | integer | - | Top-K sampling |
| presence_penalty | number | 0 | Presence penalty (-2~2) |
| frequency_penalty | number | 0 | Frequency penalty (-2~2) |
| repetition_penalty | number | 1.0 | Repetition penalty |
Tool Call Parameters
| Parameter | Type | Description |
|---|---|---|
| tools | array | Tool definition list |
| tool_choice | string/object | Tool selection strategy: none, auto, required |
Chain of Thought Parameters
| Parameter | Type | Description |
|---|---|---|
| thinking | boolean | Whether to enable chain of thought |
| reasoning_effort | string | Reasoning depth control |
Request Examples
Basic Conversation
bash
curl -X POST "https://api.uk72.cn/v1/chat/completions" \
-H "Authorization: Bearer sk-xx" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v3",
"messages": [
{"role": "user", "content": "Hello"}
]
}'Streaming Response
bash
curl -X POST "https://api.uk72.cn/v1/chat/completions" \
-H "Authorization: Bearer sk-xx" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v3",
"messages": [
{"role": "user", "content": "Hello"}
],
"stream": true
}'Parameter Best Practices
- Creative tasks: temperature 0.7-0.9
- Factual answers: temperature 0.1-0.3
- Code generation: temperature 0.1-0.3
- Reduce repetition: repetition_penalty 1.1-1.2
- Conversation scenarios: max_tokens 500-1000
Error Handling
| Status Code | Description |
|---|---|
| 400 | Parameter validation failed |
| 401 | Authentication failed |
| 429 | Rate limited |
| 500 | Internal server error |
