Anthropic SDK
AkashML exposes an Anthropic-shaped Messages API over its open source model catalog. You can point any Anthropic-compatible client (including the official anthropic SDK and Claude Code) at AkashML by setting a custom base URL.
Base URL and authentication
The Anthropic-compatible endpoints are served from:
https://api.akashml.com/anthropicAuthentication uses the same Bearer-token scheme as the OpenAI-compatible API. Pass your AkashML API key in the Authorization header:
Authorization: Bearer YOUR_API_KEYCreate and manage keys under Settings → API Keys.
Model IDs and the -- alias
Claude Code rejects model identifiers that contain /, so AkashML aliases slashes with -- on the Anthropic endpoints. To target an upstream model whose ID is zai-org/GLM-5.2, request the alias zai-org--GLM-5.2:
| Upstream ID | Anthropic-endpoint alias |
|---|---|
zai-org/GLM-5.2 | zai-org--GLM-5.2 |
meta-llama/Llama-3.3-70B-Instruct | meta-llama--Llama-3.3-70B-Instruct |
The OpenAI-compatible endpoints (/v1/*) continue to accept slashed IDs unchanged.
You can list the aliased models from GET /anthropic/v1/models.
Sending a message
The Messages endpoint is POST /anthropic/v1/messages. Required fields: model, messages, and max_tokens.
curl https://api.akashml.com/anthropic/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "zai-org--GLM-5.2",
"max_tokens": 256,
"messages": [
{ "role": "user", "content": "Hello!" }
]
}'Using the official Anthropic Python SDK:
from anthropic import Anthropic
client = Anthropic(
api_key="YOUR_API_KEY",
base_url="https://api.akashml.com/anthropic",
)
response = client.messages.create(
model="zai-org--GLM-5.2",
max_tokens=256,
messages=[
{"role": "user", "content": "Hello!"},
],
)
print(response.content[0].text)Streaming
Set stream: true to receive Server-Sent Events. The response content type switches to text/event-stream and Anthropic-shaped events are emitted:
| Event | Purpose |
|---|---|
message_start | Initial message envelope with id, model, role, usage. |
content_block_start | Start of a content block (text, tool_use, or thinking). |
content_block_delta | Incremental content (text delta, input_json_delta, thinking_delta). |
content_block_stop | End of a content block. |
message_delta | Running stop_reason and usage updates. |
message_stop | Terminal event. |
ping | Keep-alive. |
error | Terminal error event. |
Thinking mode
Models that support extended reasoning accept a thinking block:
{
"thinking": {
"type": "enabled",
"budget_tokens": 1024
}
}When enabled, the response includes thinking content blocks before the final text block.
Errors
All non-2xx responses use { type: "error", error: { type, message } }. Status-to-error.type mapping:
| Status | error.type |
|---|---|
400 | invalid_request_error |
401 | authentication_error |
403 | permission_error |
404 | not_found_error |
413 | request_too_large |
429 | rate_limit_error (response includes a Retry-After header) |
500 | api_error |
503 / 529 | overloaded_error |
API Reference
AkashML's inference API — OpenAI- and Anthropic-compatible endpoints over open source models, with full request and response schemas.
List models (Anthropic shape)
Lists available models in the Anthropic API shape. Model IDs containing `/` are aliased with `--` (e.g., `anthropic/claude-3-5-sonnet` → `anthropic--claude-3-5-sonnet`) because Claude Code rejects slashed identifiers.