Skip to content
中文

All OpenAI-format LLM Models Support the Official Claude Format

YutoAPI OpenAI-format LLM models can also be called through the Anthropic Messages endpoint. If your application, SDK, or proxy layer already sends Claude-style message payloads, point it to YutoAPI POST /v1/messages and keep using your YutoAPI Base URL and API key.

When to Use It

  • You are migrating from Claude / Anthropic Messages API to YutoAPI.
  • Your toolchain only supports Anthropic-style messages payloads.
  • You want to use both OpenAI-compatible endpoints and Claude-format endpoints under the same YutoAPI account.

How to Call It

  1. Get your Base URL and API key from the console. See Get Base URL and API Key.
  2. Set the request URL to {BaseURL}/v1/messages.
  3. Use Authorization: Bearer YOUR_API_KEY.
  4. Send model, max_tokens, messages, and related fields in Anthropic Messages format.

Minimal request example:

bash
curl --location --request POST '{BaseURL}/v1/messages' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "model": "claude-3-5-sonnet-20240620",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Explain how to integrate the YutoAPI Anthropic Messages endpoint in three sentences."
          }
        ]
      }
    ]
  }'

If your Anthropic SDK or gateway requires the official version header, you can keep:

text
anthropic-version: 2023-06-01

YutoAPI authentication still uses Authorization: Bearer YOUR_API_KEY.

Difference from OpenAI Chat Completions

ItemOpenAI-compatible formatClaude official format
Endpoint/v1/chat/completions/v1/messages
Message bodymessages[].content is usually a string or multimodal arraymessages[].content uses Anthropic content block arrays
Maximum outputUsually max_tokensmax_tokens
Model fieldmodelmodel

If your OpenAI-compatible integration already works, you do not need to migrate. Use /v1/messages when your SDK, upstream tool, or business code depends on Anthropic Messages payloads.

JavaScript Example

js
const response = await fetch(`${baseUrl}/v1/messages`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "claude-3-5-sonnet-20240620",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "text",
            text: "Summarize the integration flow for this endpoint."
          }
        ]
      }
    ]
  })
});

const data = await response.json();
console.log(data);

Notes

  • Do not put API keys in public frontend code, GitHub, logs, or screenshots.
  • model must be a model available to your account. You can check models through List Models.
  • Multimodal image requests also use /v1/messages; see Messages - Vision for an image payload example.
  • Endpoint parameter reference: Messages - Official Anthropic Format.