接口说明

文本系列接口,原生兼容 Anthropic。你可以直接使用 Anthropic 官方 SDK 进行调用。

配置信息

  • 基础地址 (Base URL): https://api.nonelinear.com/anthropic

示例代码 (Anthropic SDK)

import anthropic

client = anthropic.Anthropic(
    base_url="https://api.nonelinear.com/anthropic",
    api_key="YOUR_NONELINEAR_API_KEY",
)

message = client.messages.create(
    model="claude-haiku-4.5",
    messages=[
        {"role": "user", "content": "你好,请介绍一下你自己。"}
    ]
)
print(message.content)

cURL 调用示例

curl -sS https://api.nonelinear.com/anthropic/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-haiku-4.5",
    "max_tokens": 32,
    "messages": [
      {
        "role": "user",
        "content": "只回复 OK"
      }
    ]
  }'