# Anthropic-compatible API (/en/docs/api/compatible/anthropic)



## Base URL [#base-url]

<ApiBaseDomain prefix="/anthropic" />

## Get started [#get-started]

<QuickstartTabs snippets="{&#x22;curl&#x22;:&#x22;curl https://api-origin.invalid/anthropic/v1/messages \\\n  -H \&#x22;x-api-key: $PRAXIS_API_KEY\&#x22; \\\n  -H \&#x22;anthropic-version: 2023-06-01\&#x22; \\\n  -H \&#x22;Content-Type: application/json\&#x22; \\\n  -d '{\&#x22;model\&#x22;:\&#x22;deepseek-flash\&#x22;,\&#x22;max_tokens\&#x22;:1024,\&#x22;messages\&#x22;:[{\&#x22;role\&#x22;:\&#x22;user\&#x22;,\&#x22;content\&#x22;:\&#x22;你好\&#x22;}]}'&#x22;,&#x22;python&#x22;:&#x22;import os\n\nfrom anthropic import Anthropic\n\nclient = Anthropic(\n    base_url=\&#x22;https://api-origin.invalid/anthropic\&#x22;,\n    api_key=os.environ[\&#x22;PRAXIS_API_KEY\&#x22;],\n)\n\nresp = client.messages.create(\n    model=\&#x22;deepseek-flash\&#x22;,\n    max_tokens=1024,\n    messages=[{\&#x22;role\&#x22;: \&#x22;user\&#x22;, \&#x22;content\&#x22;: \&#x22;你好\&#x22;}],\n)&#x22;,&#x22;typescript&#x22;:&#x22;import Anthropic from \&#x22;@anthropic-ai/sdk\&#x22;;\n\nconst client = new Anthropic({\n  baseURL: \&#x22;https://api-origin.invalid/anthropic\&#x22;,\n  apiKey: process.env.PRAXIS_API_KEY,\n});\n\nconst resp = await client.messages.create({\n  model: \&#x22;deepseek-flash\&#x22;,\n  max_tokens: 1024,\n  messages: [{ role: \&#x22;user\&#x22;, content: \&#x22;你好\&#x22; }],\n});&#x22;}" />

## Endpoints [#endpoints]

| Method | Path                                                                         | Description                | Support     |
| ------ | ---------------------------------------------------------------------------- | -------------------------- | ----------- |
| POST   | [`/v1/messages`](/docs/api/compatible/anthropic/createMessage)               | Create a Message           | ● Supported |
| POST   | [`/v1/messages/count_tokens`](/docs/api/compatible/anthropic/countTokens)    | Count tokens for a request | ◐ Partial   |
| GET    | [`/v1/models`](/docs/api/compatible/anthropic/listModels)                    | List models                | ● Supported |
| POST   | [`/v1/files`](/docs/api/compatible/anthropic/createFile)                     | Upload a file              | ● Supported |
| GET    | [`/v1/files`](/docs/api/compatible/anthropic/listFiles)                      | List files                 | ● Supported |
| GET    | [`/v1/files/{file_id}`](/docs/api/compatible/anthropic/retrieveFile)         | Get file metadata          | ● Supported |
| DELETE | [`/v1/files/{file_id}`](/docs/api/compatible/anthropic/deleteFile)           | Delete a file              | ● Supported |
| GET    | [`/v1/files/{file_id}/content`](/docs/api/compatible/anthropic/downloadFile) | Download file content      | ● Supported |

## Differences from Anthropic [#differences-from-anthropic]

* <a href="/docs/api/compatible/anthropic/createMessage">Create a Message</a>：Preserves top-level cache\_control, top\_k, metadata.user\_id, output\_config.format, thinking.display and anthropic-user-profile-id. Native-only options restrict routing; requests fail when no provider can preserve them. Nonempty anthropic-workspace-id returns 400. container, inference\_geo and service\_tier are accepted and ignored; see field support for other extensions. Unknown top-level fields are forwarded unchanged to same-protocol upstream providers, which decide whether to accept them. Declared fields still undergo type and range validation; invalid values return 400 naming the field.
* <a href="/docs/api/compatible/anthropic/countTokens">Count tokens for a request</a>：Returns a model-family-calibrated estimate, including Chinese text and tool definitions, with the response header x-praxis-token-count: estimated. Do not use it as an exact usage or billing count.
* <a href="/docs/api/compatible/anthropic/listModels">List models</a>：Always returns capabilities, max\_input\_tokens and max\_tokens; unknown catalog facts are null. The total context window is not substituted for an independent input limit. Nonempty anthropic-workspace-id returns 400; anthropic-beta version selection is not implemented.
* <a href="/docs/api/compatible/anthropic/createFile">Upload a file</a>：SDK 0.128.0 sends form file and optional form expires\_in\_seconds (3600–7776000 seconds). Any other form field, including purpose, returns 400 invalid\_request\_error such as "purpose: Extra inputs are not permitted". The only accepted query parameter is the SDK's beta; other query parameters return 400, and a query expires\_in\_seconds is told to move into the form. Uploads are stored as user\_data. anthropic-workspace-id is not supported and returns 400.
* <a href="/docs/api/compatible/anthropic/listFiles">List files</a>：Newest first. Paginate with after\_id / before\_id and limit (sending both returns 400), or with the page cursor (next\_page); use only one of the three. Responses contain data, has\_more, first\_id, last\_id and next\_page. ids (up to 100 distinct IDs) is mutually exclusive with page, after\_id, before\_id and limit. scope\_id requires the anthropic-beta: managed-agents-2026-04-01 header; a missing header returns 400 and a nonexistent session scope returns 404. anthropic-workspace-id returns 400.
* <a href="/docs/api/compatible/anthropic/downloadFile">Download file content</a>：Only files produced by the code execution tool can be downloaded; downloading a file you uploaded yourself (purpose user\_data) returns 400 invalid\_request\_error, the same as Anthropic's own API.

For authoritative parameter definitions, see the [official Anthropic documentation](https://docs.anthropic.com/en/api).

Errors follow the Anthropic format, see [errors](/docs/api/errors); quotas and response headers are covered in [rate limits](/docs/api/rate-limits).
