Чат Claude
post/v1/messages
Формат Anthropic Claude Messages API. Требуется заголовок запроса anthropic-version.
Аутентификация
Передавайте ключ API OLETOKEN как Bearer-токен. Ключи создаются на странице «Ключи API» в консоли.
Authorization: Bearer $OLETOKEN_API_KEYПараметры
| Поле | Тип | Обязательный | Описание |
|---|---|---|---|
| anthropic-versionheader | string | Версия Anthropic API | |
| x-api-keyheader | string | — | Ключ Anthropic API (необязательно; также подходит Bearer-токен) |
Тело запроса
Content-Type:application/json
| Поле | Тип | Обязательный | Описание |
|---|---|---|---|
| model | string | — | |
| messages | ClaudeMessage[] | — | |
| role | stringuserassistant | — | |
| content | string | object[] | — | |
| type | stringtextimagetool_usetool_result | — | — |
| text | string | — | — |
| source | object | — | — |
| type | stringbase64url | — | — |
| media_type | string | — | — |
| data | string | — | — |
| url | string | — | — |
| id | string | — | — |
| name | string | — | — |
| input | object | — | — |
| tool_use_id | string | — | — |
| content | string | — | — |
| system | string | object[] | — | — |
| cache_control | object | — | — |
| inference_geo | string | — | — |
| max_tokens | integer≥ 1 | — | |
| temperature | number0–1 | — | — |
| top_p | number | — | — |
| top_k | integer | — | — |
| stream | boolean | — | — |
| stop_sequences | string[] | — | — |
| tools | object[] | — | — |
| name | string | — | — |
| description | string | — | — |
| input_schema | object | — | — |
| tool_choice | object | — | — |
| type | stringautoanytoolnone | — | — |
| name | string | — | — |
| thinking | object | — | — |
| type | stringenableddisabled | — | — |
| budget_tokens | integer | — | — |
| context_management | object | — | — |
| output_config | object | — | — |
| output_format | object | — | — |
| container | string | object | — | — |
| mcp_servers | object[] | — | — |
| metadata | object | — | — |
| user_id | string | — | — |
| speed | stringstandardfast | — | — |
| service_tier | stringautostandard_only | — | — |
Ответы
200Ответ создан
| Поле | Тип | Обязательный | Описание |
|---|---|---|---|
| id | string | — | — |
| type | string | — | — |
| role | string | — | — |
| content | object[] | — | — |
| type | string | — | — |
| text | string | — | — |
| model | string | — | — |
| stop_reason | stringend_turnmax_tokensstop_sequencetool_use | — | — |
| usage | object | — | — |
| input_tokens | integer | — | — |
| output_tokens | integer | — | — |
| cache_creation_input_tokens | integer | — | — |
| cache_read_input_tokens | integer | — | — |
Пример запроса
curl -X POST 'https://api.oletoken.ai/v1/messages' \
-H "Authorization: Bearer $OLETOKEN_API_KEY" \
-H 'anthropic-version:' \
-H 'x-api-key:' \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-3-opus-20240229",
"messages": [],
"max_tokens": 0
}'
