Claude
Platform Feature: OpenAI Compatibility Mode
This platform uses the OpenAI-compatible format, allowing you to easily call Anthropic's Claude series models without needing to learn new API documentation.
Core Advantage: One Codebase, Multiple Models
After getting your code working with the OpenAI format, you only need to change the model name (model) to switch to other large models like Claude or Gemini, without rewriting any code! This design makes it easy to compare the performance of different models or switch flexibly based on cost and performance needs.
Supported Anthropic Models
Claude Opus 4.7(Newest)Claude Opus 4.6Claude Opus 4.5Claude Opus 4Claude Sonnet 4.6Claude Sonnet 4.5Claude Sonnet 4Claude Haiku 4.5
Basic Information & Authentication
API Endpoint
https://api.exchangetoken.ai/v1Chat Request Path
POST /v1/chat/completionsAuthentication Method
All API requests must include authentication information in the header:
Authorization: Bearer YOUR_API_KEYRequest Parameters
Header Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
Content-Type | string | Yes | Sets the request header type, must be application/json. | application/json |
Accept | string | No | Sets the response type, recommended to be application/json. | application/json |
Authorization | string | Yes | API Key required for authentication, format: Bearer $YOUR_API_KEY. | Bearer $YOUR_API_KEY |
Body Parameters (application/json)
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
model | string | Yes | The ID of the model to use. See the available versions listed in the Overview, e.g., claude-opus-4-7. | claude-opus-4-7 |
messages | array | Yes | A list of chat messages, compatible with the OpenAI format. Each object in the array contains a role and content. | [{"role": "user", "content": "Hello"}] |
role | string | No | The role of the message author. Can be system, user, or assistant. | user |
content | string | No | The specific content of the message. | Hello, please tell me a joke. |
temperature | number | No | Sampling temperature, between 0-2. Higher values make the output more random; lower values make it more focused and deterministic. | 0.7 |
top_p | number | No | An alternative way to control sampling, between 0-1. Usually, you set either this or temperature. | 0.9 |
stream | boolean | No | Whether to enable streaming output. When set to true, returns data in a ChatGPT-like stream. | false |
max_tokens | integer | No | The maximum number of tokens to generate in a single response, limited by the model's context length. | 8192 |
reasoning_effort | string | No | Controls the amount of "computational effort" the model puts into reasoning tasks. Supports low, medium, high, none. Defaults to none. | none |
Complete Code Examples
curl -X POST "https://api.exchangetoken.ai/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4-7",
"messages": [
{"role": "system", "content": "You are a helpful AI assistant."},
{"role": "user", "content": "Hello! Please introduce yourself."}
],
"temperature": 0.7,
"max_tokens": 1000
}'from openai import OpenAI
# Initialize the client
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.exchangetoken.ai/v1"
)
# Send a chat request
response = client.chat.completions.create(
model="claude-opus-4-7",
messages=[
{"role": "system", "content": "You are a helpful AI assistant."},
{"role": "user", "content": "Hello! Please introduce yourself."}
],
temperature=0.7,
max_tokens=1000
)
print(response.choices[0].message.content)import requests
import json
url = "https://api.exchangetoken.ai/v1/chat/completions"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "claude-opus-4-7",
"messages": [
{"role": "system", "content": "You are a helpful AI assistant."},
{"role": "user", "content": "Hello! Please introduce yourself."}
],
"temperature": 0.7,
"max_tokens": 1000
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
if response.status_code == 200:
print(result["choices"][0]["message"]["content"])
else:
print(f"Error: {result}")Image Understanding
Multimodal image understanding allows you to submit images to the model by uploading them or providing an image URL.
Supported Image Types
image/pngimage/jpegimage/webpimage/gif
Upload Image via base64 (Recommended)
curl -X POST "https://api.exchangetoken.ai/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,${base64_image}"
}
}
]
}
],
"temperature": 0.7,
"max_tokens": 1024
}'Submit Image URL
curl -X POST "https://api.exchangetoken.ai/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://public_image.jpg"
}
}
]
}
],
"temperature": 0.7,
"max_tokens": 1024
}'Streaming Response
Enable Streaming Output
Set stream: true in your request:
{
"model": "claude-opus-4-7",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}Streaming Response Format
The response will be returned in Server-Sent Events (SSE) format:
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1699000000,"model":"claude-opus-4-7","choices":[{"delta":{"content":"Hello"},"index":0}]}
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1699000000,"model":"claude-opus-4-7","choices":[{"delta":{"content":" there"},"index":0}]}
data: [DONE]