> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ruapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI or Anthropic format: which one to use for Claude

> How the OpenAI-compatible and native Anthropic formats differ for Claude, which one to pick for coding agents and your own code, and what RuAPI adds over Anthropic's own layer: caching, thinking and PDFs.

You can call Claude in two formats: the native Anthropic format (the Messages API at `/v1/messages`) and the OpenAI-compatible format (Chat Completions at `/v1/chat/completions`). On RuAPI, one key works with both and the price is the same; they differ in how you write the request and which features you get. This page covers the differences and which format to choose. RuAPI works from Russia without a VPN, and you top up your balance with USDT.

## The short answer

* **If your tool lets you pick an Anthropic provider, or your app only uses Claude, use the native Anthropic format.** Requests look the same as in Anthropic's own documentation, and caching works just as it does with Anthropic: Claude Code and similar tools set the cache markers themselves. Claude Code only works in this format.
* **If your tool only supports the OpenAI format, or the same code has to switch between Claude, GPT, DeepSeek and Gemini, use the OpenAI-compatible format.** On RuAPI, caching, thinking and PDFs work in this format too; caching just needs `cache_control` markers in the request.

## How the formats differ

| | OpenAI-compatible format | Native Anthropic format |
| - | - | - |
| Request URL | `https://www.ruapi.ai/v1/chat/completions` | `https://www.ruapi.ai/v1/messages` |
| `base_url` in the SDK | `https://www.ruapi.ai/v1` | `https://www.ruapi.ai` (no `/v1`) |
| Where the key goes | `Authorization: Bearer sk-...` | `x-api-key: sk-...` or `Authorization: Bearer sk-...` |
| Models | Claude, GPT, DeepSeek, Gemini and all other chat models | Claude; DeepSeek works too, see [Claude Code on DeepSeek V4 Pro](/en/integrations/claude-code-deepseek) |
| System prompt | a `role: "system"` message in `messages` | the top-level `system` field |
| `max_tokens` | optional | required by the Anthropic spec |
| Response text | `choices[0].message.content` | `type: "text"` blocks in the `content` list |
| Thinking | `reasoning_effort`: `low`, `medium`, `high`; the thinking text is in `reasoning_content` | the `thinking` parameter; the thinking text is in `type: "thinking"` blocks |
| Tool calling | `function` entries in `tools`; results go back as `role: "tool"` messages | `input_schema` in `tools`; results go back as `tool_result` blocks |
| Images and PDFs | `image_url` and `file` blocks | `image` and `document` blocks |
| Caching | only with `cache_control` markers in the request | same as with Anthropic; Claude Code sets the markers itself |
| Usage | `prompt_tokens` already includes cached tokens; cache reads are in `prompt_tokens_details.cached_tokens` | `input_tokens` excludes cached tokens; the cache is reported separately in `cache_read_input_tokens` and `cache_creation_input_tokens` |
| Streaming | each `data:` line carries `choices[0].delta`; the last line is `data: [DONE]` | named events: `message_start`, `content_block_delta`, `message_stop` and others |
| Price | depends only on the model | depends only on the model |

## What RuAPI's OpenAI-compatible format adds over Anthropic's own

Anthropic offers its own OpenAI-compatible layer too. Its documentation says the layer is mainly meant for testing and comparing models, isn't considered a long-term or production-ready solution for most use cases, and many features don't work in it. On RuAPI, we convert OpenAI-compatible requests into native Claude requests ourselves, so all of the following works:

| Feature | Anthropic's OpenAI-compatible layer | RuAPI's OpenAI-compatible format |
| - | - | - |
| Prompt caching | not supported | supported: `cache_control` markers on content blocks and at the top level of the request, see [Prompt caching](/en/prompt-caching) |
| Thinking effort, `reasoning_effort` | ignored | passed to Claude as its thinking effort |
| Thinking text | not returned | returned in `reasoning_content` when the request sets `reasoning_effort` |
| PDFs (`file` blocks) | ignored | converted to Claude document blocks |
| Cache usage in `prompt_tokens_details` | always empty | shows how many tokens were read from the cache and written to it |
| `temperature` and `top_p` on newer models | on Claude 4.7 and later, any non-default value returns a 400 error | removed automatically, no error |

The Anthropic column is based on Anthropic's [OpenAI SDK compatibility](https://platform.claude.com/docs/en/cli-sdks-libraries/libraries/openai-sdk) documentation (checked Oct 19, 2026).

## Which one to choose

### Coding agents

| Tool | Format for Claude | URL |
| - | - | - |
| [Claude Code](/en/integrations/claude-code) | native Anthropic format only | set `ANTHROPIC_BASE_URL` to `https://www.ruapi.ai` |
| [Cline](/en/integrations/cline), [Roo Code](/en/integrations/roo-code) | the **Anthropic** provider with **Use custom base URL** checked | `https://www.ruapi.ai` |
| [Kilo Code](/en/integrations/kilo-code) | a **Custom provider** with **Provider API** set to **Anthropic Messages** | `https://www.ruapi.ai/v1` |
| [Continue](/en/integrations/continue) | `provider: anthropic` | `https://www.ruapi.ai/v1` |
| [OpenCode](/en/integrations/opencode) | the built-in `anthropic` provider | `https://www.ruapi.ai/v1` |
| [OpenClaw](/en/integrations/openclaw) | the `ANTHROPIC_BASE_URL` environment variable | `https://www.ruapi.ai` |

<Warning>
  Whether the native Anthropic URL ends in `/v1` depends on the tool: Claude Code, Cline, Roo Code, OpenClaw and the Anthropic SDK take it without `/v1`; Kilo Code, Continue and OpenCode take it with `/v1`. Enter exactly what the table says, or the connection won't work. The OpenAI-compatible URL always ends in `/v1`.
</Warning>

Other tools ([JetBrains AI Assistant](/en/integrations/jetbrains-ai-assistant), [n8n](/en/integrations/n8n), [Cherry Studio](/en/integrations/cherry-studio) and more) connect in the OpenAI-compatible format by following their own guides, at `https://www.ruapi.ai/v1`. Claude works fine this way, but if the tool doesn't set cache markers, nothing gets cached and long conversations cost more.

### Your own code

* **Claude only**: use the Anthropic SDK (`pip install anthropic`) with `base_url="https://www.ruapi.ai"`. You get the most features, and caching, thinking and PDFs are written the same way as in Anthropic's documentation.
* **Models from different vendors**: use the OpenAI SDK with `base_url="https://www.ruapi.ai/v1"`; to switch models, you only change `model`. For Claude caching, add `cache_control` markers to the request, as shown in [Prompt caching](/en/prompt-caching).

## The same request in both formats

Both snippets do the same thing: ask Claude a question with a system prompt and get its thinking text back.

<CodeGroup>
  ```python OpenAI SDK theme={null}
  from openai import OpenAI

  client = OpenAI(base_url="https://www.ruapi.ai/v1", api_key="sk-...")

  response = client.chat.completions.create(
      model="claude-sonnet-5-5",
      reasoning_effort="low",
      messages=[
          {"role": "system", "content": "You are a senior Python developer. Keep answers short."},
          {"role": "user", "content": "How do I reverse a list?"},
      ],
  )
  message = response.choices[0].message
  print(getattr(message, "reasoning_content", None))  # thinking text
  print(message.content)  # answer
  ```

  ```python Anthropic SDK theme={null}
  import anthropic

  client = anthropic.Anthropic(base_url="https://www.ruapi.ai", api_key="sk-...")

  response = client.messages.create(
      model="claude-sonnet-5-5",
      max_tokens=2048,
      thinking={"type": "adaptive", "display": "summarized"},
      system="You are a senior Python developer. Keep answers short.",
      messages=[{"role": "user", "content": "How do I reverse a list?"}],
  )
  for block in response.content:
      if block.type == "thinking":
          print(block.thinking)  # thinking text
      elif block.type == "text":
          print(block.text)  # answer
  ```
</CodeGroup>

The simplest request with curl:

<CodeGroup>
  ```bash OpenAI-compatible format theme={null}
  curl https://www.ruapi.ai/v1/chat/completions \
    -H "Authorization: Bearer sk-..." \
    -H "Content-Type: application/json" \
    -d '{"model": "claude-sonnet-5-5", "messages": [{"role": "user", "content": "Hello"}]}'
  ```

  ```bash Native Anthropic format theme={null}
  curl https://www.ruapi.ai/v1/messages \
    -H "x-api-key: sk-..." \
    -H "anthropic-version: 2023-06-01" \
    -H "Content-Type: application/json" \
    -d '{"model": "claude-sonnet-5-5", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'
  ```
</CodeGroup>

## How to tell which format you're using

Open a Claude entry in the console's **Usage Logs** and look at "Request path": `/v1/chat/completions` means the OpenAI-compatible format, `/v1/messages` means the native Anthropic format. Other ways to tell are in "Which format are you using?" on the [Prompt caching](/en/prompt-caching) page.

## FAQ

<AccordionGroup>
  <Accordion title="Is the price the same in both formats?">
    Yes. RuAPI bills by model, and the format doesn't affect the price. One key works in both formats, so you don't need a separate key.
  </Accordion>

  <Accordion title="Why does Claude drain my balance fast in the OpenAI-compatible format?">
    Most likely the cache isn't working, so the repeated context is billed at full price every time. Pick the Anthropic provider in your tool, or add `cache_control` markers to the request. For a step-by-step check, see the FAQ on the [Prompt caching](/en/prompt-caching) page.
  </Accordion>

  <Accordion title="Why does the response stop halfway?">
    Check `finish_reason` (OpenAI-compatible format) or `stop_reason` (native Anthropic format): `length` or `max_tokens` means the response hit the length limit. If the request has no `max_tokens`, RuAPI sets it to 8192 tokens; for longer responses, set a higher `max_tokens`. Thinking tokens count toward `max_tokens` too.
  </Accordion>

  <Accordion title="Why is the thinking text empty?">
    Claude 5 models (for example Sonnet 5.5, Opus 5.5 and Haiku 5.5) think by default but don't return the thinking text. In the native Anthropic format, ask for it explicitly with `thinking: {"type": "adaptive", "display": "summarized"}`. In the OpenAI-compatible format, setting `reasoning_effort` is enough: RuAPI takes care of the rest. For a simple question, Claude may answer right away without thinking, and then an empty thinking text is normal.
  </Accordion>

  <Accordion title="Why does forcing a tool call return a 400 error?">
    Claude Opus 5.5, Claude Sonnet 5.5 and Claude Fable 5.1 don't support forced tool use. Forcing a tool (`tool_choice: "required"` or a specific function name in the OpenAI-compatible format, `{"type": "any"}` or `{"type": "tool"}` in the native Anthropic format) returns a 400 error in both formats. Use `auto` and say in the prompt when the tool should be used. Source: Anthropic's [Thinking](https://platform.claude.com/docs/en/build-with-claude/thinking) documentation (checked Oct 19, 2026).
  </Accordion>

  <Accordion title="Why is there no Claude caching in the OpenAI-compatible format on another gateway?">
    Not every gateway supports it: Anthropic's own OpenAI-compatible layer doesn't support caching, and some gateways state in their docs that the cache discount only applies in the native Anthropic format. On RuAPI, Claude caching works in both formats.
  </Accordion>
</AccordionGroup>

## Next steps

* [Prompt caching](/en/prompt-caching): how to turn on Claude caching in both formats and check that it works.
* [Claude API](/en/claude-api): how the tiers differ and which one to choose.
* [Claude Code](/en/integrations/claude-code): connect Claude Code to RuAPI.
* [Function calling](/en/function-calling): a full tool-calling example.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.