Skip to content

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.6
  • Claude Opus 4.5
  • Claude Opus 4
  • Claude Sonnet 4.6
  • Claude Sonnet 4.5
  • Claude Sonnet 4
  • Claude Haiku 4.5

Basic Information & Authentication

API Endpoint

https://api.exchangetoken.ai/v1

Chat Request Path

POST /v1/chat/completions

Authentication Method

All API requests must include authentication information in the header:

Authorization: Bearer YOUR_API_KEY

Request Parameters

Header Parameters

ParameterTypeRequiredDescriptionExample
Content-TypestringYesSets the request header type, must be application/json.application/json
AcceptstringNoSets the response type, recommended to be application/json.application/json
AuthorizationstringYesAPI Key required for authentication, format: Bearer $YOUR_API_KEY.Bearer $YOUR_API_KEY

Body Parameters (application/json)

ParameterTypeRequiredDescriptionExample
modelstringYesThe ID of the model to use. See the available versions listed in the Overview, e.g., claude-opus-4-7.claude-opus-4-7
messagesarrayYesA list of chat messages, compatible with the OpenAI format. Each object in the array contains a role and content.[{"role": "user", "content": "Hello"}]
  rolestringNoThe role of the message author. Can be system, user, or assistant.user
  contentstringNoThe specific content of the message.Hello, please tell me a joke.
temperaturenumberNoSampling temperature, between 0-2. Higher values make the output more random; lower values make it more focused and deterministic.0.7
top_pnumberNoAn alternative way to control sampling, between 0-1. Usually, you set either this or temperature.0.9
streambooleanNoWhether to enable streaming output. When set to true, returns data in a ChatGPT-like stream.false
max_tokensintegerNoThe maximum number of tokens to generate in a single response, limited by the model's context length.8192
reasoning_effortstringNoControls the amount of "computational effort" the model puts into reasoning tasks. Supports low, medium, high, none. Defaults to none.none

Complete Code Examples

bash
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
  }'
python
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)
python
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/png
  • image/jpeg
  • image/webp
  • image/gif
bash
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

bash
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:

json
{
  "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]