示例

集成示例

Get from zero to your first response in minutes. Pick the client you already use — the endpoint is fully compatible.

Good to know All examples use the same endpoint. To switch models, change only the "model" value — no other code changes required.

The fastest way to test your key from any terminal.

cURL curl https://clauden.ai/v1/chat/completions \ -H "Authorization: Bearer $CLAUDEN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "messages": [{"role": "user", "content": "Hello!"}] }'

Use the official OpenAI SDK — just point base_url at ClaudeN AI.

OpenAI Python SDK from openai import OpenAI client = OpenAI( api_key="$CLAUDEN_API_KEY", base_url="https://clauden.ai/v1", ) resp = client.chat.completions.create( model="gpt-5.4", messages=[{"role": "user", "content": "Hello!"}], ) print(resp.choices[0].message.content)

Prefer the Anthropic SDK? Use the /v1/anthropic base URL.

Anthropic Python SDK from anthropic import Anthropic client = Anthropic( api_key="$CLAUDEN_API_KEY", base_url="https://clauden.ai/v1/anthropic", ) msg = client.messages.create( model="claude-sonnet-4-6", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}], ) print(msg.content[0].text)

Node.js with the official OpenAI SDK — only baseURL and apiKey change.

OpenAI Node.js SDK import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.CLAUDEN_API_KEY, baseURL: "https://clauden.ai/v1", }); const resp = await client.chat.completions.create({ model: "gpt-5.4", messages: [{ role: "user", content: "Hello!" }], }); console.log(resp.choices[0].message.content);

Streaming works the same way as with OpenAI: pass stream=True and iterate the chunks.

Python streaming stream = client.chat.completions.create( model="claude-sonnet-4-6", messages=[{"role": "user", "content": "Hello!"}], stream=True, ) for chunk in stream: delta = chunk.choices[0].delta.content if delta: print(delta, end="", flush=True)

Editors & agent frameworks

Cursor: Settings → Models → check "Override OpenAI Base URL", set it to the base URL below, paste your ClaudeN API key, then add model names such as claude-sonnet-4-6 or gpt-5.4 to the model list.

Cline / Continue: choose the "OpenAI Compatible" provider, set the same base URL and API key, and pick any enabled model name. LangChain and LlamaIndex work through their standard OpenAI classes with a custom base_url.

Base URL https://clauden.ai/v1

请将 $CLAUDEN_API_KEY 替换为你自己的 API 密钥(以 sk- 开头),它会通过 Authorization 请求头发送。

获取你的 API 密钥 快速开始 →

注册即享 $5 免费额度