> 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

Call GPT-6.1 Sol, GPT-6 Astra, GPT-6 Sol and GPT-6 Luna through one OpenAI Chat Completions endpoint with a BeatAPI key.- One endpoint, `POST /v1/chat/completions`, for every current GPT model. Change `model` to switch.
- Text and image input, text output, streaming, function calling, structured outputs and configurable reasoning effort.
- Works with the OpenAI SDK: change the base URL and use a BeatAPI key.
- For new reasoning and tool-calling integrations, [OpenAI Responses](/text-api/gpt/responses) is the recommended format.Use `https://direct.beatapi.io` as the base URL for text requests: it is not subject to Cloudflare's 100-second limit, so a long non-streaming request is not cut off. `https://api.beatapi.io` also works and is the fallback if `direct.beatapi.io` is unreachable from your network. The key, models and prices are the same on both. Image and video APIs use `https://api.beatapi.io` only.POST/v1/chat/completionsTry itOpens this endpoint in the API Explorer. Enter your BeatAPI API key and send: the call is real and is billed to your own balance.## ModelsSend one of these IDs as `model`. Each is a separate model; do not treat them as aliases of each other.| Model ID      | Context (tokens) | Max output (tokens) | Positioning                                                                                  | Input, USD per 1M tokens | Output, USD per 1M tokens | Notes                                                                      |
| ------------- | ---------------- | ------------------- | -------------------------------------------------------------------------------------------- | ------------------------ | ------------------------- | -------------------------------------------------------------------------- |
| `gpt-6.1-sol` | 1,050,000        | 128,000             | GPT-6.1 Sol for coding, computer use, and professional work. Use Responses for tool calling. | \$0.80                   | \$4.00                    | Reasoning effort `low` to `max`. Higher rate above 272K input tokens.      |
| `gpt-6-astra` | 1,000,000        | 128,000             | Most capable GPT model: complex reasoning, coding, computer use, research and document work  | \$4.00                   | \$20.00                   | Higher rate above 272K input tokens.                                       |
| `gpt-6-sol`   | 1,050,000        | 128,000             | Mid-tier GPT-6 model for everyday coding, research, and agentic work at a lower price        | \$0.80                   | \$4.00                    | A separate model from GPT-6.1 Sol and GPT-5.6 Sol.                         |
| `gpt-6-luna`  | 1,050,000        | 128,000             | Cost-efficient GPT-6 model for focused, high-volume tasks                                    | \$0.04                   | \$0.20                    | High-volume, focused tasks such as extraction, classification and routing. |- Prices are the base tier, discount already applied. A long-context tier, cached-input rates and cache writes are not in this table; see the [price table](https://beatapi.io/pricing).
- `—` means the catalogue does not publish the number.Older IDs of this family still work and are listed on [Legacy models](/text-api/legacy-models).## Quick startInstall the `openai` package on your server, keep the key in `BEATAPI_API_KEY`, and never put it in browser code. These are request examples, not recorded model outputs.Read the answer from `choices[0].message.content`, then check `finish_reason` and `usage`. An HTTP 200 alone does not prove the answer satisfies your task: validate it in your application. Text requests return directly; do not poll `/v1/tasks` for them.```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);
```## Endpoint and authentication`POST https://direct.beatapi.io/v1/chat/completions`Authorization
string
Required`Bearer <BEATAPI_API_KEY>`. The key works with or without the `sk-` prefix.## Request parametersStandard OpenAI Chat Completions fields are accepted. Request-format compatibility does not mean every provider-specific option or tool is supported, so test the options you rely on.model
string
RequiredThe exact model ID.**Allowed values**: `gpt-6.1-sol`, `gpt-6-astra`, `gpt-6-sol`, `gpt-6-luna`- Older IDs that still work (`gpt-5.6-sol`, `gpt-5.6-terra`, `gpt-5.6-luna`) are on [Legacy models](/text-api/legacy-models).
- Call `GET /v1/models` with your key to confirm which models are enabled for it.messages
object[]
RequiredThe conversation, oldest message first. Each message has a `role` and `content`. `content` is a string, or an array of parts for text and image input.- Image input is supported by all GPT models on this page.max_tokens
integer
OptionalUpper bound on the generated tokens.- The gateway accepts values up to 1,073,741,823; a larger value is `400 bad_request`.
- The gateway does not compare your value with the model's max output from the table above. Keep it at or below that number.
- `max_tokens` is also used to estimate how much balance a request needs. A very large value can be refused with `402 insufficient_credits` even when the real output would be small. Set it to what you need.stream
boolean
OptionalDefault: falseReturn the answer as server-sent events. See the Streaming section below.**Default**: `false`reasoning_effort
string
OptionalHow much reasoning the model does before answering. Start with `medium`, then evaluate one level lower and higher on your own workload.**Allowed values**: `none`, `low`, `medium`, `high`, `xhigh`, `max`**Per model**- `gpt-6.1-sol`: `low`, `medium`, `high`, `xhigh` and `max`. `none` and `minimal` are not supported.
- `gpt-5.6-sol`: `none`, `low`, `medium`, `high`, `xhigh` and `max`.
- `gpt-5.6-terra`: `none`, `low`, `medium`, `high`, `xhigh` and `max`.
- `gpt-5.6-luna`: `none`, `low`, `medium`, `high`, `xhigh` and `max`.tools
object[]
OptionalFunction definitions the model may call. Return the tool result in a following `tool` message.response_format
object
OptionalAsk for structured output, for example a JSON schema.## ResponseA non-streaming call returns one JSON object. This is an abbreviated example.```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
  }
}
```### Response fields| Field                       | Type     | Description                                                                                 |
| --------------------------- | -------- | ------------------------------------------------------------------------------------------- |
| `id`                        | `string` | The completion ID. Log it, together with the request ID, for support and billing audits.    |
| `model`                     | `string` | The model that answered.                                                                    |
| `choices[].message.content` | `string` | The answer text.                                                                            |
| `choices[].finish_reason`   | `string` | `stop` for a complete answer. A truncated answer or a tool request needs separate handling. |
| `usage`                     | `object` | Token counts. Calls are metered from actual token usage.                                    |## StreamingSet `"stream": true`. BeatAPI forwards the server-sent event stream without converting it, so event objects stay compatible with the OpenAI SDK.- The response is `text/event-stream`; without streaming it is `application/json`.
- A failure before the model is called is returned as a normal JSON error with an HTTP status, not as a stream event.
- Set explicit timeouts and reconnect a streamed response safely.```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]
```## Errors| Error or symptom                                         | Cause                                                                                                         | Fix                                                                     |
| -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `400` with a reasoning effort the model does not support | For example `none` on `gpt-6.1-sol`.                                                                          | Use a value the model supports; see `reasoning_effort` above.           |
| `402 insufficient_credits`                               | Balance below the price of the request, often because `max_tokens` is very large.                             | Top up, or lower `max_tokens`.                                          |
| `403 forbidden`                                          | The account is on free credit and the model is not on the free list, or the model is outside the key's group. | Top up, use a free model, or use a key whose group can reach the model. |
| `404 not_found`                                          | Unknown model ID, or not enabled for this key.                                                                | List the enabled models with `GET /v1/models`.                          |
| `429 rate_limit_exceeded`                                | Account or free-model limit reached.                                                                          | Wait `Retry-After`, then retry.                                         |### HTTP errors at a glanceAuthentication, routing, rate-limit and unknown-model failures are answered before the model is called, in the BeatAPI envelope: `error.code`, `error.message`, `retryable`, `request_id`. Every other failure keeps the OpenAI SDK shape `{"error": {"message", "type", "code"}}`: the code is in `error.code` and the request id ends `message`. See [Errors](/errors#text-endpoints).| HTTP status | Code                                                       | What to do                                                                                   |
| ----------- | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| 400         | `bad_request`, `content_policy_violation`                  | Fix the request or the input; do not resend it unchanged.                                    |
| 401         | `missing_api_key`, `invalid_api_key`                       | Check the key. Do not retry.                                                                 |
| 402         | `insufficient_credits`                                     | Top up, or raise the key's limit. A very large `max_tokens` can trigger it.                  |
| 403         | `forbidden`                                                | The model is outside the key's group or IP allowlist, or free credit cannot call this model. |
| 404         | `not_found`                                                | Unknown model: list the enabled ones with `GET /v1/models`.                                  |
| 429         | `rate_limit_exceeded`                                      | Wait `Retry-After` or `retry_after_seconds`, then retry with backoff.                        |
| 500         | `internal_error`, `temporary_error`                        | Retry once or twice with backoff.                                                            |
| 503         | `model_unavailable`, `upstream_timeout`, `temporary_error` | Retry with backoff, or use another model.                                                    |Full code table and retry policy: [Errors](/errors#text-endpoints).## Notes- GPT models also answer on [OpenAI Responses](/text-api/gpt/responses).
- Above 272K input tokens, `gpt-6.1-sol` and `gpt-6-astra` use a higher tier for the full request. See the [price table](https://beatapi.io/pricing) before budgeting a long-context workload.
- Keep API keys on trusted servers, log the response request ID, and retry only `429`, `500` and `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) — The exact model ID. Older IDs that still work (`gpt-5.6-sol`, `gpt-5.6-terra`, `gpt-5.6-luna`) are on [Legacy models](/text-api/legacy-models). Call `GET /v1/models` with your key to confirm which models are enabled for it. `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) — The conversation, oldest message first. Each message has a `role` and `content`. `content` is a string, or an array of parts for text and image input. Image input is supported by all GPT models on this page.
- `max_tokens` (integer, optional) — Upper bound on the generated tokens. The gateway accepts values up to 1,073,741,823; a larger value is `400 bad_request`. The gateway does not compare your value with the model's max output from the table above. Keep it at or below that number. `max_tokens` is also used to estimate how much balance a request needs. A very large value can be refused with `402 insufficient_credits` even when the real output would be small. Set it to what you need.
- `stream` (boolean, optional, default: false) — Return the answer as server-sent events. See the Streaming section below.
- `reasoning_effort` (enum, optional) — How much reasoning the model does before answering. Start with `medium`, then evaluate one level lower and higher on your own workload. `gpt-6.1-sol`: `low`, `medium`, `high`, `xhigh` and `max`. `none` and `minimal` are not supported. `gpt-5.6-sol`: `none`, `low`, `medium`, `high`, `xhigh` and `max`. `gpt-5.6-terra`: `none`, `low`, `medium`, `high`, `xhigh` and `max`. `gpt-5.6-luna`: `none`, `low`, `medium`, `high`, `xhigh` and `max`. `none`, `low`, `medium`, `high`, `xhigh`, `max`
  - Allowed values: `none`, `low`, `medium`, `high`, `xhigh`, `max`
- `tools` (list of V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaToolsItems, optional) — Function definitions the model may call. Return the tool result in a following `tool` message.
- `response_format` (V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaResponseFormat, optional) — Ask for structured output, for example a JSON schema.

## Response

### 200

A non-streaming call returns one JSON object. This is an abbreviated example.

- `id` (string, optional) — The completion ID. Log it, together with the request ID, for support and billing audits.
- `model` (string, optional) — The model that answered.
- `choices` (list of V1ChatCompletionsPostResponsesContentApplicationJsonSchemaChoicesItems, optional)
- `usage` (V1ChatCompletionsPostResponsesContentApplicationJsonSchemaUsage, optional) — Token counts. Calls are metered from actual token usage.

## Errors

### 400 Bad Request Error

`bad_request`, `content_policy_violation` Fix the request or the input; do not resend it unchanged. Authentication, routing, rate-limit and unknown-model failures are answered before the model is called, in the BeatAPI envelope: `error.code`, `error.message`, `retryable`, `request_id`. Every other failure keeps the OpenAI SDK shape `{"error": {"message", "type", "code"}}`: the code is in `error.code` and the request id ends `message`. See [Errors](/errors#text-endpoints).

- `map from string to any`

### 401 Unauthorized Error

`missing_api_key`, `invalid_api_key` Check the key. Do not retry. Authentication, routing, rate-limit and unknown-model failures are answered before the model is called, in the BeatAPI envelope: `error.code`, `error.message`, `retryable`, `request_id`. Every other failure keeps the OpenAI SDK shape `{"error": {"message", "type", "code"}}`: the code is in `error.code` and the request id ends `message`. See [Errors](/errors#text-endpoints).

- `map from string to any`

### 402 Payment Required Error

`insufficient_credits` Top up, or raise the key's limit. A very large `max_tokens` can trigger it. Authentication, routing, rate-limit and unknown-model failures are answered before the model is called, in the BeatAPI envelope: `error.code`, `error.message`, `retryable`, `request_id`. Every other failure keeps the OpenAI SDK shape `{"error": {"message", "type", "code"}}`: the code is in `error.code` and the request id ends `message`. See [Errors](/errors#text-endpoints).

- `map from string to any`

### 403 Forbidden Error

`forbidden` The model is outside the key's group or IP allowlist, or free credit cannot call this model. Authentication, routing, rate-limit and unknown-model failures are answered before the model is called, in the BeatAPI envelope: `error.code`, `error.message`, `retryable`, `request_id`. Every other failure keeps the OpenAI SDK shape `{"error": {"message", "type", "code"}}`: the code is in `error.code` and the request id ends `message`. See [Errors](/errors#text-endpoints).

- `map from string to any`

### 404 Not Found Error

`not_found` Unknown model: list the enabled ones with `GET /v1/models`. Authentication, routing, rate-limit and unknown-model failures are answered before the model is called, in the BeatAPI envelope: `error.code`, `error.message`, `retryable`, `request_id`. Every other failure keeps the OpenAI SDK shape `{"error": {"message", "type", "code"}}`: the code is in `error.code` and the request id ends `message`. See [Errors](/errors#text-endpoints).

- `map from string to any`

### 429 Too Many Requests Error

`rate_limit_exceeded` Wait `Retry-After` or `retry_after_seconds`, then retry with backoff. Authentication, routing, rate-limit and unknown-model failures are answered before the model is called, in the BeatAPI envelope: `error.code`, `error.message`, `retryable`, `request_id`. Every other failure keeps the OpenAI SDK shape `{"error": {"message", "type", "code"}}`: the code is in `error.code` and the request id ends `message`. See [Errors](/errors#text-endpoints).

- `map from string to any`

### 500 Internal Server Error

`internal_error`, `temporary_error` Retry once or twice with backoff. Authentication, routing, rate-limit and unknown-model failures are answered before the model is called, in the BeatAPI envelope: `error.code`, `error.message`, `retryable`, `request_id`. Every other failure keeps the OpenAI SDK shape `{"error": {"message", "type", "code"}}`: the code is in `error.code` and the request id ends `message`. See [Errors](/errors#text-endpoints).

- `map from string to any`

### 503 Service Unavailable Error

`model_unavailable`, `upstream_timeout`, `temporary_error` Retry with backoff, or use another model. Authentication, routing, rate-limit and unknown-model failures are answered before the model is called, in the BeatAPI envelope: `error.code`, `error.message`, `retryable`, `request_id`. Every other failure keeps the OpenAI SDK shape `{"error": {"message", "type", "code"}}`: the code is in `error.code` and the request id ends `message`. See [Errors](/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

Ask for structured output, for example a JSON schema.

### V1ChatCompletionsPostResponsesContentApplicationJsonSchemaChoicesItems

- `message` (V1ChatCompletionsPostResponsesContentApplicationJsonSchemaChoicesItemsMessage, optional)
- `finish_reason` (string, optional) — `stop` for a complete answer. A truncated answer or a tool request needs separate handling.

### V1ChatCompletionsPostResponsesContentApplicationJsonSchemaUsage

Token counts. Calls are metered from actual token usage.

### V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItemsContent

### V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItemsToolCallsItems

### V1ChatCompletionsPostResponsesContentApplicationJsonSchemaChoicesItemsMessage

- `content` (string, optional) — The answer text.

## 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 Quick start
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 Quick start
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 Quick start
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 Quick start
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 Quick start
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 Quick start
<?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 Quick start
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 Quick start
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()
```