DeepAnima
Kouri Ai

Anthropic Compatible API

Call Claude models using native Anthropic protocol or OpenAI-compatible protocol

Kouri Ai's Claude models support both native Anthropic protocol and OpenAI-compatible protocol. We recommend using the native protocol for richer features, better stability, and support for advanced capabilities like extended thinking.

Protocol Selection

Protocol TypeEndpoint URLDescription
Anthropic Protocolhttps://api.kourichat.com/v1/messagesNative protocol, recommended, supports all models
OpenAI Protocolhttps://api.kourichat.com/v1Compatible protocol for simple scenarios

Native Anthropic protocol recommended: Major applications like Dify, Chatbox, and Cherry Studio all support the native protocol with full features. OpenAI-compatible protocol is only recommended for applications that only support OpenAI format.

Common configuration error: Many users select OpenAI format in their software but fill in the anthropic address, causing request failures. Make sure the protocol type matches the endpoint URL.

Native Anthropic Protocol

cURL Request

curl https://api.kourichat.com/v1/messages \
  -H "x-api-key: sk-xxxxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-4-5-20250929",
    "max_tokens": 1024,
    "stream": false,
    "messages": [
        {"role": "user", "content": "Hello!"}
    ]
  }'

Python SDK

Using the official Anthropic Python SDK:

from anthropic import Anthropic

client = Anthropic(
    base_url='https://api.kourichat.com',
    api_key='sk-xxxxxxxx',  # Replace with your Kouri Ai token
)

message = client.messages.create(
    model="claude-sonnet-4-5-20250929",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Hello, Claude!"}
    ]
)

print(message.content[0].text)

Streaming

from anthropic import Anthropic

client = Anthropic(
    base_url='https://api.kourichat.com',
    api_key='sk-xxxxxxxx',
)

with client.messages.stream(
    model="claude-sonnet-4-5-20250929",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Tell me a story"}
    ]
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

System Prompt

from anthropic import Anthropic

client = Anthropic(
    base_url='https://api.kourichat.com',
    api_key='sk-xxxxxxxx',
)

message = client.messages.create(
    model="claude-sonnet-4-5-20250929",
    max_tokens=1024,
    system="You are a professional translator. Please translate the user's input to English.",
    messages=[
        {"role": "user", "content": "今天天气真好"}
    ]
)

print(message.content[0].text)

OpenAI Compatible Protocol

If your application only supports OpenAI format, you can use the compatible protocol:

cURL Request

curl https://api.kourichat.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxx" \
  -d '{
    "model": "claude-sonnet-4-5-20250929",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Python

from openai import OpenAI

client = OpenAI(
    base_url='https://api.kourichat.com/v1',
    api_key='sk-xxxxxxxx',
)

response = client.chat.completions.create(
    model="claude-sonnet-4-5-20250929",
    messages=[
        {"role": "user", "content": "Hello!"}
    ]
)

print(response.choices[0].message.content)

JavaScript

import OpenAI from 'openai';

const client = new OpenAI({
    baseURL: 'https://api.kourichat.com/v1',
    apiKey: 'sk-xxxxxxxx',
});

const response = await client.chat.completions.create({
    model: 'claude-sonnet-4-5-20250929',
    messages: [
        { role: 'user', content: 'Hello!' }
    ]
});

console.log(response.choices[0].message.content);

Multimodal (Image Understanding)

Claude supports image input:

from anthropic import Anthropic
import base64

client = Anthropic(
    base_url='https://api.kourichat.com',
    api_key='sk-xxxxxxxx',
)

# Using URL
message = client.messages.create(
    model="claude-sonnet-4-5-20250929",
    max_tokens=1024,
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "image",
                    "source": {
                        "type": "url",
                        "url": "https://example.com/image.jpg"
                    }
                },
                {
                    "type": "text",
                    "text": "Describe this image"
                }
            ]
        }
    ]
)

print(message.content[0].text)
from openai import OpenAI

client = OpenAI(
    base_url='https://api.kourichat.com/v1',
    api_key='sk-xxxxxxxx',
)

response = client.chat.completions.create(
    model="claude-sonnet-4-5-20250929",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Describe this image"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://example.com/image.jpg"
                    }
                }
            ]
        }
    ]
)

print(response.choices[0].message.content)

Common Parameters

ParameterTypeRequiredDescription
modelstringModel name
messagesarrayMessage list
max_tokensintegerMaximum output tokens
systemstringSystem prompt
temperaturenumberRandomness, 0-1
streambooleanEnable streaming
thinkingobjectExtended thinking config

More Resources

On this page