# 相容格式

> 使用 OpenAI、Anthropic 和 Gemini 請求格式接入 LLMoxy。

LLMoxy 支援多種請求格式，已有應用通常只需要替換 Base URL 和 API Key 即可遷移。

## OpenAI 相容

OpenAI SDK 配置：

```ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.LLMOXY_API_KEY,
  baseURL: "https://llmoxy.com/v1",
});
```

主要路由：

| 路由 | 用途 |
| --- | --- |
| `POST /v1/chat/completions` | Chat Completions。 |
| `POST /v1/completions` | 舊文字補全。 |
| `POST /v1/responses` | Responses API。 |
| `POST /v1/embeddings` | Embeddings。 |
| `POST /v1/images/generations` | 圖像生成。 |
| `POST /v1/audio/transcriptions` | 音訊轉錄。 |
| `POST /v1/audio/translations` | 音訊翻譯。 |
| `POST /v1/audio/speech` | 文字轉語音。 |
| `GET /v1/realtime` | Realtime WebSocket。 |

## Anthropic Messages

```bash
curl https://llmoxy.com/v1/messages \
  -H "x-api-key: <LLMOXY_API_KEY>" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-5-5",
    "max_tokens": 256,
    "messages": [
      { "role": "user", "content": "Hello" }
    ]
  }'
```

Anthropic 路由接受 `system`、`max_tokens`、`temperature`、`top_p`、`top_k`、`stop_sequences`、`tools`、`tool_choice`、`thinking`、`metadata.user_id` 等欄位。

## Gemini

```bash
curl "https://llmoxy.com/v1beta/models/gemini-4-argon:generateContent" \
  -H "x-goog-api-key: <LLMOXY_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [{ "text": "Explain LLMoxy in one sentence." }]
      }
    ]
  }'
```

Gemini 風格模型列表可使用 `GET /v1beta/models`。

## 尚未實現的相容路由

當前 Relay 對以下 OpenAI 相容路由返回未實現：

- `POST /v1/images/variations`
- `/v1/files`
- `/v1/fine-tunes`
- `DELETE /v1/models/{model}`

本文是 https://tw.llmoxy.com/docs/api-reference/compatibility 的 markdown 版本。
