OpenAI・Anthropic 互換性
すでに OpenAI や Anthropic の SDK をお使いですか?ベース URL と API キーの 2 点を変更するだけで Nexevo を指せるようになります。既存のコードはそのまま動作し、すべての呼び出しに Nexevo のスマートルーティング、課金、BYOK が適用されます。
エンドポイント
POST/v1/chat/completions — OpenAI Chat Completions
POST/v1/messages — Anthropic Messages
どちらも各ベンダーの正確な通信フォーマット(ストリーミング・非ストリーミング)でやり取りするため、公式 SDK がそのまま動作します。これは「SDK はありますか?」という問いへの答えでもあります——お手持ちの OpenAI または Anthropic SDK をそのままお使いください。
認証
ワークスペース API キーを使用します——REST API と同じキーです。呼び出しを 1 つのワークスペースに紐づけます;OpenAI サーフェスは Authorization: Bearer ヘッダーから、Anthropic サーフェスは x-api-key から読み取ります。SDK は api_key オプションからこれらを自動的に設定します。
モデルの選択
モデルに "nexevo-auto" を渡すと、Nexevo のルーターが各リクエストに最適なモデルを選びます。明示的な Nexevo モデル id を渡して固定することもできます。不明なモデル id は 404 を返します。
OpenAI —— Python
from openai import OpenAI
client = OpenAI(
base_url="https://nexevo.ai/v1",
api_key="sk-ws-...", # your Nexevo workspace API key
)
resp = client.chat.completions.create(
model="nexevo-auto", # or an explicit Nexevo model id
messages=[{"role": "user", "content": "Summarize our Q2 results."}],
)
print(resp.choices[0].message.content)ストリーミング
stream = client.chat.completions.create(
model="nexevo-auto",
messages=[{"role": "user", "content": "Write a short product update."}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="", flush=True)OpenAI —— JavaScript / TypeScript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://nexevo.ai/v1",
apiKey: process.env.NEXEVO_API_KEY, // your workspace API key
});
const resp = await client.chat.completions.create({
model: "nexevo-auto",
messages: [{ role: "user", content: "Summarize our Q2 results." }],
});
console.log(resp.choices[0].message.content);OpenAI —— curl
curl https://nexevo.ai/v1/chat/completions \\
-H "Authorization: Bearer sk-ws-..." \\
-H "Content-Type: application/json" \\
-d '{
"model": "nexevo-auto",
"messages": [{"role": "user", "content": "Hello"}]
}'Anthropic —— Python
Anthropic SDK はベース URL に /v1/messages を付加するため、ベース URL には https://nexevo.ai を設定してください。
from anthropic import Anthropic
client = Anthropic(
base_url="https://nexevo.ai",
api_key="sk-ws-...", # your Nexevo workspace API key
)
msg = client.messages.create(
model="nexevo-auto",
max_tokens=1024,
messages=[{"role": "user", "content": "Summarize our Q2 results."}],
)
print(msg.content[0].text)Anthropic —— curl
curl https://nexevo.ai/v1/messages \\
-H "x-api-key: sk-ws-..." \\
-H "anthropic-version: 2023-06-01" \\
-H "Content-Type: application/json" \\
-d '{
"model": "nexevo-auto",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello"}]
}'課金はネイティブのチャットレーンと全く同じです(スマートルーティング、フラットな料金表)。ワークスペースの BYOK キーが設定されていれば自動的に使用されます。レスポンスの token usage はベストエフォートの推定値です。これらのサーフェスでは推論やツール呼び出しのフレームは送出されず、assistant のテキストのみが返ります。