> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# GPT Chat Completions

POST https://direct.beatapi.io/v1/chat/completions
Content-Type: application/json

1 つの BeatAPI キーで、同じ OpenAI Chat Completions エンドポイントから GPT-6.1 Sol、GPT-6 Astra、GPT-6 Sol、GPT-6 Luna を呼び出せます。- 1 つのエンドポイント `POST /v1/chat/completions` で、現行の GPT モデルすべてを呼び出せます。`model` を変えるだけで切り替わります。
- テキストと画像の入力、テキスト出力、ストリーミング、関数呼び出し、構造化出力、推論強度の設定に対応します。
- OpenAI SDK で使えます。base URL を変え、BeatAPI のキーを使うだけです。
- 新しい推論・ツール呼び出しの連携には [OpenAI Responses](/text-api/gpt/responses) を推奨します。テキストリクエストの base URL には `https://direct.beatapi.io` を推奨します。Cloudflare の 100 秒制限を受けないため、長時間のノンストリーミングリクエストが途中で切れません。`https://api.beatapi.io` も使え、ネットワークから `direct.beatapi.io` に届かない場合の代替になります。キー、モデル、価格はどちらも同じです。画像・動画 API は `https://api.beatapi.io` のみを使います。POST/v1/chat/completions試してみるこのエンドポイントをテスト画面で開きます。BeatAPI の API キーを入力して送信してください。実際に呼び出され、ご自身の残高から課金されます。## モデル次の ID のいずれかを `model` として送ります。それぞれ別のモデルで、互いのエイリアスではありません。| モデル ID        | コンテキスト（トークン） | 最大出力（トークン） | 位置づけ                                                         | 入力、USD / 100 万トークン | 出力、USD / 100 万トークン | 備考                                                |
| ------------- | ------------ | ---------- | ------------------------------------------------------------ | ------------------ | ------------------ | ------------------------------------------------- |
| `gpt-6.1-sol` | 1,050,000    | 128,000    | コーディング、コンピューター操作、専門業務向けの GPT-6.1 Sol。ツール呼び出しには Responses を使用 | \$0.80             | \$4.00             | 推論強度は `low` から `max`。入力が 27.2 万トークンを超えると料金が上がります。 |
| `gpt-6-astra` | 1,000,000    | 128,000    | 最も高性能な GPT モデル。複雑な推論、コーディング、コンピューター操作、リサーチ、文書作成向け            | \$4.00             | \$20.00            | 入力が 27.2 万トークンを超えると料金が上がります。                      |
| `gpt-6-sol`   | 1,050,000    | 128,000    | 日常のコーディング、リサーチ、エージェントタスクを低価格で利用できる中位の GPT-6 モデル              | \$0.80             | \$4.00             | GPT-6.1 Sol や GPT-5.6 Sol とは別のモデルです。              |
| `gpt-6-luna`  | 1,050,000    | 128,000    | 用途が明確な大量処理向けの、費用効率に優れた GPT-6 モデル                             | \$0.04             | \$0.20             | 抽出、分類、ルーティングなど、大量で目的の絞られたタスク向け。                   |- 価格は基本ティアで、割引適用後です。長文コンテキストのティア、キャッシュ入力価格、キャッシュ書き込み価格はこの表に含まれません。[価格表](https://beatapi.io/pricing)を参照してください。
- `—` はカタログが数値を公開していないことを示します。このファミリーの旧 ID は引き続き使え、[旧モデル](/text-api/legacy-models)にまとめています。## クイックスタートサーバーに `openai` パッケージをインストールし、キーは `BEATAPI_API_KEY` に置いて、ブラウザーのコードには入れないでください。以下はリクエスト例であり、実際のモデル出力の記録ではありません。回答は `choices[0].message.content` から読み取り、`finish_reason` と `usage` を確認します。HTTP 200 だけでは回答がタスクを満たす証拠になりません。アプリケーション側で内容を検証してください。テキストリクエストは直接結果を返すので、`/v1/tasks` をポーリングする必要はありません。```bash title="cURL"
curl --request POST \
  --url https://direct.beatapi.io/v1/chat/completions \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-6-luna",
  "messages": [
    {
      "role": "user",
      "content": "Design a resilient webhook retry strategy for a payments API."
    }
  ]
}'
``````python title="Python"
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["BEATAPI_API_KEY"], base_url="https://direct.beatapi.io/v1")
completion = client.chat.completions.create(
    model="gpt-6-luna",
    messages=[
      {
        "role": "user",
        "content": "Design a resilient webhook retry strategy for a payments API."
      }
    ],
)
print(completion.choices[0].message.content)
``````javascript title="JavaScript"
import OpenAI from "openai";

const client = new OpenAI({ apiKey: process.env.BEATAPI_API_KEY, baseURL: "https://direct.beatapi.io/v1" });
const completion = await client.chat.completions.create({
  "model": "gpt-6-luna",
  "messages": [
    {
      "role": "user",
      "content": "Design a resilient webhook retry strategy for a payments API."
    }
  ]
});
console.log(completion.choices[0].message.content);
```## エンドポイントと認証`POST https://direct.beatapi.io/v1/chat/completions`Authorization
string
必須`Bearer <BEATAPI_API_KEY>`。キーは `sk-` プレフィックスの有無どちらでも使えます。## リクエストパラメーター標準の OpenAI Chat Completions のフィールドを受け付けます。リクエスト形式の互換性は、プロバイダー固有のオプションやツールがすべて使えることを意味しません。使用するオプションは必ずテストしてください。model
string
必須正確なモデル ID。**指定できる値**：`gpt-6.1-sol`, `gpt-6-astra`, `gpt-6-sol`, `gpt-6-luna`- 引き続き使える旧 ID（`gpt-5.6-sol`、`gpt-5.6-terra`、`gpt-5.6-luna`）は[旧モデル](/text-api/legacy-models)にあります。
- キーで `GET /v1/models` を呼び出し、そのキーで有効なモデルを確認してください。messages
object[]
必須会話の内容。古いメッセージが先頭です。各メッセージには `role` と `content` があります。`content` は文字列、またはテキストと画像のパーツの配列です。- このページのすべての GPT モデルが画像入力に対応しています。max_tokens
integer
任意生成するトークン数の上限。- ゲートウェイが受け付ける最大値は 1,073,741,823 で、これを超えると `400 bad_request` になります。
- ゲートウェイは、指定値を上の表のモデル最大出力と比較しません。その数値以下に収めてください。
- `max_tokens` は、リクエストに必要な残高の見積もりにも使われます。実際の出力が短くても、非常に大きい値は `402 insufficient_credits` で拒否されることがあります。必要な値を指定してください。stream
boolean
任意デフォルト: false回答をサーバー送信イベントで返します。下のストリーミングの節を参照してください。**デフォルト**：`false`reasoning_effort
string
任意回答する前の推論の強さ。まず `medium` から始め、実際のワークロードで 1 段階下と上を評価してください。**指定できる値**：`none`, `low`, `medium`, `high`, `xhigh`, `max`**モデルごとの注意**- `gpt-6.1-sol`：`low`、`medium`、`high`、`xhigh`、`max`。`none` と `minimal` は使えません。
- `gpt-5.6-sol`：`none`、`low`、`medium`、`high`、`xhigh`、`max`。
- `gpt-5.6-terra`：`none`、`low`、`medium`、`high`、`xhigh`、`max`。
- `gpt-5.6-luna`：`none`、`low`、`medium`、`high`、`xhigh`、`max`。tools
object[]
任意モデルが呼び出せる関数の定義。ツールの結果は、続く `tool` メッセージで返します。response_format
object
任意構造化出力（たとえば JSON スキーマ）を要求します。## レスポンスストリーミングなしの呼び出しは、1 つの JSON オブジェクトを返します。以下は一部を省略した例です。```json
{
  "id": "chatcmpl-example",
  "object": "chat.completion",
  "created": 1791993600,
  "model": "gpt-6-luna",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Retry with exponential backoff and jitter, and make every handler idempotent."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 19,
    "completion_tokens": 16,
    "total_tokens": 35
  }
}
```### レスポンスのフィールド| フィールド                       | 型        | 説明                                                     |
| --------------------------- | -------- | ------------------------------------------------------ |
| `id`                        | `string` | 補完 ID。サポートや請求の照合のため、リクエスト ID と一緒に記録してください。             |
| `model`                     | `string` | 実際に回答したモデル。                                            |
| `choices[].message.content` | `string` | 回答テキスト。                                                |
| `choices[].finish_reason`   | `string` | `stop` は回答が完結していることを示します。回答の途中切れやツール呼び出しの要求は別途処理が必要です。 |
| `usage`                     | `object` | トークン数。呼び出しは実際のトークン使用量で課金されます。                          |## ストリーミング`"stream": true` を指定します。BeatAPI はサーバー送信イベントのストリームを変換せずに転送するため、イベントオブジェクトは OpenAI SDK と互換のままです。- レスポンスは `text/event-stream` です。ストリーミングなしの場合は `application/json` です。
- モデルを呼ぶ前に起きた失敗は、ストリームイベントではなく、HTTP ステータス付きの通常の JSON エラーで返されます。
- 明示的なタイムアウトを設定し、ストリーミングレスポンスを安全に再接続してください。```text
data: {"id":"chatcmpl-example","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":"Retry"},"finish_reason":null}]}

data: {"id":"chatcmpl-example","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" with backoff"},"finish_reason":null}]}

data: {"id":"chatcmpl-example","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]
```## エラー| エラーまたは症状                   | 原因                                                 | 対処                                           |
| -------------------------- | -------------------------------------------------- | -------------------------------------------- |
| `400`：モデルが対応しない推論強度        | 例：`gpt-6.1-sol` で `none` を指定した。                    | モデルが対応する値を使ってください。上の `reasoning_effort` を参照。 |
| `402 insufficient_credits` | 残高がリクエストの価格を下回っています。`max_tokens` が非常に大きいことが多い原因です。 | チャージするか、`max_tokens` を下げてください。               |
| `403 forbidden`            | アカウントが無料クレジットで、モデルが無料リストにない、またはモデルがキーのグループの範囲外です。  | チャージする、無料モデルを使う、またはグループがそのモデルに届くキーを使ってください。  |
| `404 not_found`            | モデル ID が存在しない、またはこのキーで有効になっていません。                  | `GET /v1/models` で有効なモデルを確認してください。           |
| `429 rate_limit_exceeded`  | アカウントまたは無料モデルの上限に達しました。                            | `Retry-After` だけ待ってから再試行してください。              |### HTTP エラー早見表認証、ルーティング、レート制限、存在しないモデルの失敗はモデルを呼ぶ前に起き、BeatAPI のエンベロープ（`error.code`、`error.message`、`retryable`、`request_id`）で返ります。それ以外の失敗は OpenAI SDK の形式 `{"error": {"message", "type", "code"}}` のままで、コードは `error.code`、request id は `message` の末尾にあります。詳しくは[エラー](/errors#text-endpoints)を参照してください。| HTTP ステータス | エラーコード                                                   | 対応                                                             |
| ---------- | -------------------------------------------------------- | -------------------------------------------------------------- |
| 400        | `bad_request`、`content_policy_violation`                 | リクエストか入力を直してください。そのまま再送しないでください。                               |
| 401        | `missing_api_key`、`invalid_api_key`                      | キーを確認してください。再試行しないでください。                                       |
| 402        | `insufficient_credits`                                   | チャージするか、キーの上限を上げてください。`max_tokens` が非常に大きい場合も発生します。            |
| 403        | `forbidden`                                              | モデルがキーのグループまたは IP 許可リストの範囲外、または無料クレジットでは呼べないモデルです。             |
| 404        | `not_found`                                              | モデルが存在しません。`GET /v1/models` で有効なモデルを確認してください。                  |
| 429        | `rate_limit_exceeded`                                    | `Retry-After` または `retry_after_seconds` だけ待ち、バックオフして再試行してください。 |
| 500        | `internal_error`、`temporary_error`                       | バックオフして 1～2 回再試行してください。                                        |
| 503        | `model_unavailable`、`upstream_timeout`、`temporary_error` | バックオフして再試行するか、別のモデルを使ってください。                                   |全エラーコード表と再試行ポリシーは[エラー](/errors#text-endpoints)を参照してください。## 注意事項- GPT モデルは [OpenAI Responses](/text-api/gpt/responses) でも呼び出せます。
- 入力が 27.2 万トークンを超えると、`gpt-6.1-sol` と `gpt-6-astra` はリクエスト全体に上位ティアが適用されます。長文コンテキストの運用を見積もる前に[価格表](https://beatapi.io/pricing)を確認してください。
- キーは信頼できるサーバーだけに置き、レスポンスのリクエスト ID を記録し、再試行は `429`、`500`、`503` に限ってください。

Reference: https://docs.beatapi.io/api-reference/text-api/gpt-chat-completions

## Authentication

- `Authorization` header (bearer token, required) — Send your API key as `Authorization: Bearer <BEATAPI_API_KEY>`.

## Servers

- `https://direct.beatapi.io` (Direct, default)
- `https://api.beatapi.io` (API)

## Request

### Body (application/json)

This endpoint expects an object.

- `model` (enum, required) — 正確なモデル ID。 引き続き使える旧 ID（`gpt-5.6-sol`、`gpt-5.6-terra`、`gpt-5.6-luna`）は[旧モデル](/text-api/legacy-models)にあります。 キーで `GET /v1/models` を呼び出し、そのキーで有効なモデルを確認してください。 `gpt-6.1-sol`, `gpt-6-astra`, `gpt-6-sol`, `gpt-6-luna`
  - Allowed values: `gpt-6.1-sol`, `gpt-6-astra`, `gpt-6-sol`, `gpt-6-luna`
- `messages` (list of V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItems, required) — 会話の内容。古いメッセージが先頭です。各メッセージには `role` と `content` があります。`content` は文字列、またはテキストと画像のパーツの配列です。 このページのすべての GPT モデルが画像入力に対応しています。
- `max_tokens` (integer, optional) — 生成するトークン数の上限。 ゲートウェイが受け付ける最大値は 1,073,741,823 で、これを超えると `400 bad_request` になります。 ゲートウェイは、指定値を上の表のモデル最大出力と比較しません。その数値以下に収めてください。 `max_tokens` は、リクエストに必要な残高の見積もりにも使われます。実際の出力が短くても、非常に大きい値は `402 insufficient_credits` で拒否されることがあります。必要な値を指定してください。
- `stream` (boolean, optional, default: false) — 回答をサーバー送信イベントで返します。下のストリーミングの節を参照してください。
- `reasoning_effort` (enum, optional) — 回答する前の推論の強さ。まず `medium` から始め、実際のワークロードで 1 段階下と上を評価してください。 `gpt-6.1-sol`: `low`、`medium`、`high`、`xhigh`、`max`。`none` と `minimal` は使えません。 `gpt-5.6-sol`: `none`、`low`、`medium`、`high`、`xhigh`、`max`。 `gpt-5.6-terra`: `none`、`low`、`medium`、`high`、`xhigh`、`max`。 `gpt-5.6-luna`: `none`、`low`、`medium`、`high`、`xhigh`、`max`。 `none`, `low`, `medium`, `high`, `xhigh`, `max`
  - Allowed values: `none`, `low`, `medium`, `high`, `xhigh`, `max`
- `tools` (list of V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaToolsItems, optional) — モデルが呼び出せる関数の定義。ツールの結果は、続く `tool` メッセージで返します。
- `response_format` (V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaResponseFormat, optional) — 構造化出力（たとえば JSON スキーマ）を要求します。

## Response

### 200

ストリーミングなしの呼び出しは、1 つの JSON オブジェクトを返します。以下は一部を省略した例です。

- `id` (string, optional) — 補完 ID。サポートや請求の照合のため、リクエスト ID と一緒に記録してください。
- `model` (string, optional) — 実際に回答したモデル。
- `choices` (list of V1ChatCompletionsPostResponsesContentApplicationJsonSchemaChoicesItems, optional)
- `usage` (V1ChatCompletionsPostResponsesContentApplicationJsonSchemaUsage, optional) — トークン数。呼び出しは実際のトークン使用量で課金されます。

## Errors

### 400 Bad Request Error

`bad_request`、`content_policy_violation` リクエストか入力を直してください。そのまま再送しないでください。 認証、ルーティング、レート制限、存在しないモデルの失敗はモデルを呼ぶ前に起き、BeatAPI のエンベロープ（`error.code`、`error.message`、`retryable`、`request_id`）で返ります。それ以外の失敗は OpenAI SDK の形式 `{"error": {"message", "type", "code"}}` のままで、コードは `error.code`、request id は `message` の末尾にあります。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 401 Unauthorized Error

`missing_api_key`、`invalid_api_key` キーを確認してください。再試行しないでください。 認証、ルーティング、レート制限、存在しないモデルの失敗はモデルを呼ぶ前に起き、BeatAPI のエンベロープ（`error.code`、`error.message`、`retryable`、`request_id`）で返ります。それ以外の失敗は OpenAI SDK の形式 `{"error": {"message", "type", "code"}}` のままで、コードは `error.code`、request id は `message` の末尾にあります。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 402 Payment Required Error

`insufficient_credits` チャージするか、キーの上限を上げてください。`max_tokens` が非常に大きい場合も発生します。 認証、ルーティング、レート制限、存在しないモデルの失敗はモデルを呼ぶ前に起き、BeatAPI のエンベロープ（`error.code`、`error.message`、`retryable`、`request_id`）で返ります。それ以外の失敗は OpenAI SDK の形式 `{"error": {"message", "type", "code"}}` のままで、コードは `error.code`、request id は `message` の末尾にあります。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 403 Forbidden Error

`forbidden` モデルがキーのグループまたは IP 許可リストの範囲外、または無料クレジットでは呼べないモデルです。 認証、ルーティング、レート制限、存在しないモデルの失敗はモデルを呼ぶ前に起き、BeatAPI のエンベロープ（`error.code`、`error.message`、`retryable`、`request_id`）で返ります。それ以外の失敗は OpenAI SDK の形式 `{"error": {"message", "type", "code"}}` のままで、コードは `error.code`、request id は `message` の末尾にあります。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 404 Not Found Error

`not_found` モデルが存在しません。`GET /v1/models` で有効なモデルを確認してください。 認証、ルーティング、レート制限、存在しないモデルの失敗はモデルを呼ぶ前に起き、BeatAPI のエンベロープ（`error.code`、`error.message`、`retryable`、`request_id`）で返ります。それ以外の失敗は OpenAI SDK の形式 `{"error": {"message", "type", "code"}}` のままで、コードは `error.code`、request id は `message` の末尾にあります。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 429 Too Many Requests Error

`rate_limit_exceeded` `Retry-After` または `retry_after_seconds` だけ待ち、バックオフして再試行してください。 認証、ルーティング、レート制限、存在しないモデルの失敗はモデルを呼ぶ前に起き、BeatAPI のエンベロープ（`error.code`、`error.message`、`retryable`、`request_id`）で返ります。それ以外の失敗は OpenAI SDK の形式 `{"error": {"message", "type", "code"}}` のままで、コードは `error.code`、request id は `message` の末尾にあります。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 500 Internal Server Error

`internal_error`、`temporary_error` バックオフして 1～2 回再試行してください。 認証、ルーティング、レート制限、存在しないモデルの失敗はモデルを呼ぶ前に起き、BeatAPI のエンベロープ（`error.code`、`error.message`、`retryable`、`request_id`）で返ります。それ以外の失敗は OpenAI SDK の形式 `{"error": {"message", "type", "code"}}` のままで、コードは `error.code`、request id は `message` の末尾にあります。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 503 Service Unavailable Error

`model_unavailable`、`upstream_timeout`、`temporary_error` バックオフして再試行するか、別のモデルを使ってください。 認証、ルーティング、レート制限、存在しないモデルの失敗はモデルを呼ぶ前に起き、BeatAPI のエンベロープ（`error.code`、`error.message`、`retryable`、`request_id`）で返ります。それ以外の失敗は OpenAI SDK の形式 `{"error": {"message", "type", "code"}}` のままで、コードは `error.code`、request id は `message` の末尾にあります。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

## Types

### V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItems

- `role` (string, required)
- `content` (V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItemsContent, optional, nullable)
- `name` (string, optional)
- `tool_call_id` (string, optional)
- `tool_calls` (list of V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItemsToolCallsItems, optional)

### V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaToolsItems

### V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaResponseFormat

構造化出力（たとえば JSON スキーマ）を要求します。

### V1ChatCompletionsPostResponsesContentApplicationJsonSchemaChoicesItems

- `message` (V1ChatCompletionsPostResponsesContentApplicationJsonSchemaChoicesItemsMessage, optional)
- `finish_reason` (string, optional) — `stop` は回答が完結していることを示します。回答の途中切れやツール呼び出しの要求は別途処理が必要です。

### V1ChatCompletionsPostResponsesContentApplicationJsonSchemaUsage

トークン数。呼び出しは実際のトークン使用量で課金されます。

### V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItemsContent

### V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItemsToolCallsItems

### V1ChatCompletionsPostResponsesContentApplicationJsonSchemaChoicesItemsMessage

- `content` (string, optional) — 回答テキスト。

## Examples

**Request**

```json
{
  "model": "gpt-6-luna",
  "messages": [
    {
      "role": "user",
      "content": "Design a resilient webhook retry strategy for a payments API."
    }
  ]
}
```

**Response**

```json
{
  "id": "chatcmpl-example",
  "model": "gpt-6-luna",
  "choices": [
    {
      "message": {
        "content": "Retry with exponential backoff and jitter, and make every handler idempotent.",
        "role": "assistant"
      },
      "finish_reason": "stop",
      "index": 0
    }
  ],
  "usage": {
    "completion_tokens": 16,
    "prompt_tokens": 19,
    "total_tokens": 35
  },
  "created": 1791993600,
  "object": "chat.completion"
}
```

**SDK Code**

```python クイックスタート
import requests

url = "https://direct.beatapi.io/v1/chat/completions"

payload = {
    "model": "gpt-6-luna",
    "messages": [
        {
            "role": "user",
            "content": "Design a resilient webhook retry strategy for a payments API."
        }
    ]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript クイックスタート
const url = 'https://direct.beatapi.io/v1/chat/completions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"gpt-6-luna","messages":[{"role":"user","content":"Design a resilient webhook retry strategy for a payments API."}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go クイックスタート
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://direct.beatapi.io/v1/chat/completions"

	payload := strings.NewReader("{\n  \"model\": \"gpt-6-luna\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Design a resilient webhook retry strategy for a payments API.\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby クイックスタート
require 'uri'
require 'net/http'

url = URI("https://direct.beatapi.io/v1/chat/completions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"gpt-6-luna\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Design a resilient webhook retry strategy for a payments API.\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java クイックスタート
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://direct.beatapi.io/v1/chat/completions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"gpt-6-luna\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Design a resilient webhook retry strategy for a payments API.\"\n    }\n  ]\n}")
  .asString();
```

```php クイックスタート
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://direct.beatapi.io/v1/chat/completions', [
  'body' => '{
  "model": "gpt-6-luna",
  "messages": [
    {
      "role": "user",
      "content": "Design a resilient webhook retry strategy for a payments API."
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp クイックスタート
using RestSharp;

var client = new RestClient("https://direct.beatapi.io/v1/chat/completions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"gpt-6-luna\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Design a resilient webhook retry strategy for a payments API.\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift クイックスタート
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "gpt-6-luna",
  "messages": [
    [
      "role": "user",
      "content": "Design a resilient webhook retry strategy for a payments API."
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://direct.beatapi.io/v1/chat/completions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```