Claude API Access Guide: Native Anthropic Interface and Key Configuration
Access Anthropic Claude models via the AzzTimes gateway: learn about endpoints, authentication, cURL examples, request/response fields, SSE streaming, and common error codes.
1. Overview
AzzTimes provides a proxy gateway compatible with the Anthropic Messages API (/v1/messages) for developers. Simply point your requests to our gateway and replace your authentication key with the sk- key generated in the "User Center - API Keys" section to start using Claude models directly, without changing your existing code.
The currently available models are listed in the Model Square (e.g., claude-sonnet-5, claude-opus-5, claude-sonnet-4-6, claude-opus-4-8, etc.). The complete list and unit pricing can be queried at any time via GET /v1/models.
2. API Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /v1/messages | Proxy forwarding entrance; request body follows Anthropic /v1/messages payload structure |
| GET | /v1/models | List of models and unit prices (no authentication required) |
Gateway address: https://www.relay-api.com. Follow the table above for request paths.
3. Authentication
Generate a key in "User Center → API Keys" in the format sk-xxxxxxxx. Include it in your requests using one of the following methods:
- Authorization Header:
Authorization: Bearer sk-your-key(Recommended, compatible with most SDKs) - x-api-key Header:
x-api-key: sk-your-key
If the key is invalid, disabled, or the balance is insufficient, the system will return 401 or 403. Please verify your key status and account balance.
4. Quick Start (cURL)
4.1 Non-streaming Chat
curl -X POST https://www.relay-api.com/v1/messages \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-key" \
-d '{
"model": "claude-sonnet-5",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Introduce yourself in one sentence"}
]
}'
4.2 Multi-turn conversation with system prompts
curl -X POST https://www.relay-api.com/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-your-key" \
-d '{
"model": "claude-opus-5",
"max_tokens": 2048,
"system": "You are a rigorous technical documentation engineer.",
"messages": [
{"role": "user", "content": "What are the authentication headers for the Claude Messages API?"},
{"role": "assistant", "content": "Use x-api-key or Authorization: Bearer to carry your key."},
{"role": "user", "content": "Give me an example of a streaming request."}
],
"metadata": {"request_id": "demo-001"}
}'
The metadata.request_id is saved in usage logs, making it easy to reconcile accounts under "User Center → Usage Details".
5. Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model slug, e.g., claude-sonnet-5 |
| max_tokens | int | Yes | Max output tokens, recommended 1~64000 |
| messages | array | Yes | Conversation messages, items are {role, content}, role: user / assistant |
| system | string | No | System prompt |
| temperature | number | No | Sampling temperature, default 1.0, range 0~1 |
| top_p | number | No | Nucleus sampling, default 0.999 |
| stream | bool | No | Streaming output, default false |
| stop_sequences | array | No | Stop sequences |
| metadata.request_id | string | No | Custom request ID for reconciliation |
6. Response Structure
Non-streaming requests return the standard Anthropic Messages structure:
{
"id": "msg_01ABCDEFG",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-5",
"content": [
{"type": "text", "text": "Hello! I am Claude."}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 12,
"output_tokens": 18,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0
}
}
| Field | Description |
|---|---|
| id | Unique message ID |
| content[].type | Content block type, text / thinking, etc. |
| content[].text | Text content |
| stop_reason | Stop reason: end_turn / max_tokens / stop_sequence |
| usage.input_tokens | Input token count (basis for billing) |
| usage.output_tokens | Output token count (basis for billing) |
| usage.cache_read_input_tokens | Cached input tokens read (billed at cache read rate) |
| usage.cache_creation_input_tokens | Tokens written to cache (billed at cache write rate) |
7. Streaming Output
When the request body includes "stream": true, the server returns data in chunks via SSE (Server-Sent Events). The event types are identical to Anthropic's:
event: message_start
data: {"type": "message_start", "message": {"id": "msg_...", "model": "claude-sonnet-5"}}
event: content_block_delta
data: {"type": "content_block_delta", "delta": {"type": "text_delta", "text": "Hello"}}
event: message_delta
data: {"type": "message_delta", "delta": {"stop_reason": "end_turn"}, "usage": {"output_tokens": 18}}
event: message_stop
data: {"type": "message_stop"}
Clients should parse the JSON after the data: prefix and ignore event: lines and empty lines. Receiving message_stop indicates the end of the stream. Billing is settled on the server side based on the total usage of the request, independent of the streaming process.
8. Common Error Codes
| HTTP Status | Meaning | Resolution |
|---|---|---|
| 400 | Invalid request parameters (missing model/max_tokens, model not enabled, etc.) | Correct the request body based on the response message |
| 401 | Missing or invalid API key | Check your Authorization / x-api-key headers |
| 403 | Key disabled, insufficient balance, or model/route not authorized | Top up your account, check key status, or adjust permissions |
| 404 | Model does not exist | Check available models via GET /v1/models |
| 429 | Too many requests or rate limit triggered | Retry with exponential backoff |
| 500 | Internal server error | Retry later; contact support if the issue persists |
The error response body format is consistent: {"code": status_code, "message": "error description", "data": null}.
9. Usage and Balance
- Each call is deducted in real-time based on token usage × model unit price × route multiplier. See
GET /v1/modelsfor specific pricing and routes. - After logging in, view your call history (model, tokens, cost, status) in "User Center → API Usage".
- If your balance is insufficient, the request will return 403; access is restored immediately upon top-up.
