You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
server : add Anthropic Messages API support (#17570)
* server : add Anthropic Messages API support
* remove -@pytest.mark.slow from tool calling/jinja tests
* server : remove unused code and slow/skip on test_anthropic_vision_base64_with_multimodal_model in test_anthropic_api.py
* server : removed redundant n field logic in anthropic_params_from_json
* server : use single error object instead of error_array in streaming response handler for /v1/chat/completions and use unordered_set instead of set in to_json_anthropic_stream()
* server : refactor Anthropic API to use OAI conversion
* make sure basic test always go first
* clean up
* clean up api key check, add test
---------
Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
@@ -1352,6 +1353,77 @@ See [OpenAI Embeddings API documentation](https://platform.openai.com/docs/api-r
1352
1353
}'
1353
1354
```
1354
1355
1356
+
### POST `/v1/messages`: Anthropic-compatible Messages API
1357
+
1358
+
Given a list of `messages`, returns the assistant's response. Streaming is supported via Server-Sent Events. While no strong claims of compatibility with the Anthropic API spec are made, in our experience it suffices to support many apps.
1359
+
1360
+
*Options:*
1361
+
1362
+
See [Anthropic Messages API documentation](https://docs.anthropic.com/en/api/messages). Tool use requires `--jinja` flag.
1363
+
1364
+
`model`: Model identifier (required)
1365
+
1366
+
`messages`: Array of message objects with `role` and `content` (required)
1367
+
1368
+
`max_tokens`: Maximum tokens to generate (default: 4096)
1369
+
1370
+
`system`: System prompt as string or array of content blocks
1371
+
1372
+
`temperature`: Sampling temperature 0-1 (default: 1.0)
1373
+
1374
+
`top_p`: Nucleus sampling (default: 1.0)
1375
+
1376
+
`top_k`: Top-k sampling
1377
+
1378
+
`stop_sequences`: Array of stop sequences
1379
+
1380
+
`stream`: Enable streaming (default: false)
1381
+
1382
+
`tools`: Array of tool definitions (requires `--jinja`)
0 commit comments