> 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.

# MiniMax Responses

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

用一个 BeatAPI 密钥，通过 OpenAI Responses API 调用 MiniMax M3。- 一个端点 `POST /v1/responses` 即可调用 MiniMax M3。
- 支持流式输出和函数调用，上下文窗口为 100 万 token。提示词超过 512,000 token 后费率翻倍。
- 兼容 OpenAI SDK：改 base URL，换成 BeatAPI 密钥即可。已有的 Chat Completions 集成见 [Chat Completions](/text-api/minimax/chat-completions)。
- 服务端不保存会话状态：每一轮都要把完整历史放进 `input`。文本请求建议使用 `https://direct.beatapi.io` 作为 base URL：它不受 Cloudflare 100 秒限制，长时间的非流式请求不会被中途切断。`https://api.beatapi.io` 同样可用；如果你的网络访问不了 `direct.beatapi.io`，请改用它作为备用。两个域名的密钥、模型和价格完全一致。图片和视频 API 只使用 `https://api.beatapi.io`。POST/v1/responses试一试在调试窗口里打开本接口，填入你的 BeatAPI API 密钥即可发送。调用是真实的，费用从你自己的余额中扣除。## 模型把下面的 ID 作为 `model` 发送。| 模型 ID        | 上下文（tokens） | 最大输出（tokens） | 定位                              | 输入，美元 / 100 万 tokens | 输出，美元 / 100 万 tokens | 说明                                                         |
| ------------ | ----------- | ------------ | ------------------------------- | -------------------- | -------------------- | ---------------------------------------------------------- |
| `MiniMax-M3` | 1,048,576   | 128,000      | MiniMax 多模态模型，面向长上下文编程、感知与智能体规划 | \$0.21               | \$0.84               | MiniMax 多模态模型，适合长上下文编程、感知与智能体规划。提示词超过 512,000 token 后费率翻倍。 |- 价格为基础档，已计入折扣。长上下文档、缓存命中输入价和缓存写入价不在本表内，见[价格表](https://beatapi.io/pricing)。
- `—` 表示目录未公布该数字。## 快速开始在服务端安装 `openai` 包，把密钥放在 `BEATAPI_API_KEY`，不要把它写进浏览器代码。`output_text` 是 SDK 提供的取答案文本的快捷属性。以下是请求示例，不是真实的模型输出记录。从 `output_text`（或 `output` 里 `output_text` 类型的片段）读取答案，再检查 `status` 和 `usage`。HTTP 200 不能证明答案满足你的任务，请在应用里校验内容。文本请求直接返回，不要为它们轮询 `/v1/tasks`。```bash title="cURL"
curl --request POST \
  --url https://direct.beatapi.io/v1/responses \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "MiniMax-M3",
  "max_output_tokens": 2000,
  "input": "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")
response = client.responses.create(
    model="MiniMax-M3",
    max_output_tokens=2000,
    input="Design a resilient webhook retry strategy for a payments API.",
)
print(response.output_text)
``````javascript title="JavaScript"
import OpenAI from "openai";

const client = new OpenAI({ apiKey: process.env.BEATAPI_API_KEY, baseURL: "https://direct.beatapi.io/v1" });
const response = await client.responses.create({
  "model": "MiniMax-M3",
  "max_output_tokens": 2000,
  "input": "Design a resilient webhook retry strategy for a payments API."
});
console.log(response.output_text);
```## 端点与鉴权`POST https://direct.beatapi.io/v1/responses`Authorization
string
必需`Bearer <BEATAPI_API_KEY>`。密钥带不带 `sk-` 前缀都可以。## 请求参数接受标准的 OpenAI Responses 字段。请求格式兼容，不代表每个模型都支持所有选项或托管工具，请对你依赖的选项自行测试。model
string
必需准确的模型 ID。**可选值**：`MiniMax-M3`- 每个 ID 都是独立的模型，不是其他模型的别名。
- 用你的密钥调用 `GET /v1/models`，确认该密钥已开通哪些模型。
- ID 区分大小写：请发送 `MiniMax-M3`，不要写成 `minimax-m3`。input
string | object[]
必需提示词：可以是字符串，也可以是输入项数组，例如消息、函数调用及其输出。服务端不保存会话状态。不支持 `previous_response_id`、`conversation`、`prompt` 和 `context_management`：每一轮都要把完整历史放进 `input`。instructions
string
可选放在 `input` 之前的系统级指令。max_output_tokens
integer
可选生成 token 数的上限，包含推理部分。- 网关不会拿你的值去和上面表格里的最大输出比较，请自己控制在该数字以内。
- 这个值也用来估算一次请求需要多少余额。值特别大时，即使实际输出很短，也可能被 `402 insufficient_credits` 拒绝。按实际需要设置即可。推理型号会先输出推理内容。`max_output_tokens` 太小时，推理可能把额度用完，答案文本会为空或被截断。请给推理和正文都留出空间，遇到这种情况就调大。stream
boolean
可选默认值: false以服务端推送事件（SSE）返回答案。见下文「流式输出」。**默认值**：`false`temperature
number
可选采样温度。它和 `top_p` 调一个就行，不要两个一起改。top_p
number
可选核采样阈值。tools
object[]
可选模型可以调用的函数工具。模型会返回 `function_call` 输出项；把结果作为带相同 `call_id` 的 `function_call_output` 输入项传回。托管工具（联网搜索、文件检索等）不在此列。tool_choice
string | object
可选控制模型可以、必须或不得调用工具。请用你的模型测试你依赖的取值。## 长上下文计费`MiniMax-M3` 在提示词超过 **512,000 token** 后进入更高的费率档，更高的费率对整次请求生效：输入、缓存输入和输出的费率都翻倍。这是阶梯，不是逐步上涨：只超过一个 token 的请求，也整单按更高费率计费。上面模型表和[价格表](https://beatapi.io/pricing)里的价格是基础费率，适用于未超过阈值的提示词。发送很长的历史之前，先估算完整提示词的长度。## 响应非流式调用返回一个 JSON 对象。以下是精简后的示例。```json
{
  "id": "resp_example",
  "object": "response",
  "model": "MiniMax-M3",
  "status": "completed",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Retry with exponential backoff and jitter, and make every handler idempotent."
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 19,
    "output_tokens": 16,
    "total_tokens": 35
  }
}
```### 响应字段| 字段                        | 类型         | 说明                                                                            |
| ------------------------- | ---------- | ----------------------------------------------------------------------------- |
| `id`                      | `string`   | 响应 ID。请连同请求 ID 一起记录，方便售后和对账。                                                  |
| `model`                   | `string`   | 实际作答的模型。                                                                      |
| `status`                  | `string`   | `completed` 表示作答完成。                                                           |
| `output[]`                | `object[]` | 输出项：`message`、`reasoning` 和 `function_call`。SDK 的 `output_text` 会帮你拼接其中的文本片段。 |
| `output[].content[].text` | `string`   | `message` 输出项的答案文本，位于类型为 `output_text` 的片段里。                                  |
| `usage`                   | `object`   | token 数量。调用按实际 token 用量计量。                                                    |## 流式输出设置 `"stream": true`。流以 `response.created` 开始，答案通过 `response.output_text.delta` 事件逐段到达，最后以 `response.completed` 结束。- 响应类型是 `text/event-stream`；不流式时是 `application/json`。
- 函数调用是单独的输出项，它的参数通过 `response.function_call_arguments.delta` 事件逐段到达。
- 调用模型之前就失败的请求，返回的是带 HTTP 状态码的普通 JSON 错误，而不是流事件。
- 请设置明确的超时，并安全地重连流式响应。```text
event: response.created
data: {"type":"response.created","response":{"id":"resp_example","status":"in_progress"}}

event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":"Retry"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":" with backoff"}

event: response.completed
data: {"type":"response.completed","response":{"id":"resp_example","status":"completed"}}
```## 错误| 错误或现象                                                                      | 原因                                         | 处理                                   |
| -------------------------------------------------------------------------- | ------------------------------------------ | ------------------------------------ |
| 答案文本为空或被截断                                                                 | 推理型号把整个 `max_output_tokens` 额度都用在了推理上。     | 调大 `max_output_tokens`，但不要超过模型的最大输出。 |
| 报错提到 `previous_response_id`、`conversation`、`prompt` 或 `context_management` | 这些有状态字段不受支持。                               | 删掉它们，把完整历史放进 `input`。                |
| `402 insufficient_credits`                                                 | 余额低于这次请求的价格，常见原因是 `max_output_tokens` 特别大。 | 充值，或调小 `max_output_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`                       | 退避后重试一两次。                                       |
| 503      | `model_unavailable`、`upstream_timeout`、`temporary_error` | 退避重试，或换用其他模型。                                   |完整的错误码表和重试策略见[错误码](/errors#text-endpoints)。## 注意事项- MiniMax 也可以用 [Chat Completions](/text-api/minimax/chat-completions) 和 [Anthropic Messages](/text-api/minimax/messages) 调用。
- 本页介绍 MiniMax 文本模型。MiniMax H3 视频模型使用 Video API。
- 密钥只放在可信的服务端，记录响应里的请求 ID，只对 `429`、`500` 和 `503` 重试。

Reference: https://docs.beatapi.io/api-reference/text-api/minimax-responses

## 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 都是独立的模型，不是其他模型的别名。 用你的密钥调用 `GET /v1/models`，确认该密钥已开通哪些模型。 ID 区分大小写：请发送 `MiniMax-M3`，不要写成 `minimax-m3`。 `MiniMax-M3`
  - Allowed values: `MiniMax-M3`
- `input` (V1ResponsesPostRequestBodyContentApplicationJsonSchemaInput, required) — 提示词：可以是字符串，也可以是输入项数组，例如消息、函数调用及其输出。 服务端不保存会话状态。不支持 `previous_response_id`、`conversation`、`prompt` 和 `context_management`：每一轮都要把完整历史放进 `input`。
- `instructions` (string, optional) — 放在 `input` 之前的系统级指令。
- `max_output_tokens` (integer, optional) — 生成 token 数的上限，包含推理部分。 网关不会拿你的值去和上面表格里的最大输出比较，请自己控制在该数字以内。 这个值也用来估算一次请求需要多少余额。值特别大时，即使实际输出很短，也可能被 `402 insufficient_credits` 拒绝。按实际需要设置即可。 推理型号会先输出推理内容。`max_output_tokens` 太小时，推理可能把额度用完，答案文本会为空或被截断。请给推理和正文都留出空间，遇到这种情况就调大。
- `stream` (boolean, optional, default: false) — 以服务端推送事件（SSE）返回答案。见下文「流式输出」。
- `temperature` (double, optional) — 采样温度。它和 `top_p` 调一个就行，不要两个一起改。
- `top_p` (double, optional) — 核采样阈值。
- `tools` (list of V1ResponsesPostRequestBodyContentApplicationJsonSchemaToolsItems, optional) — 模型可以调用的函数工具。模型会返回 `function_call` 输出项；把结果作为带相同 `call_id` 的 `function_call_output` 输入项传回。托管工具（联网搜索、文件检索等）不在此列。
- `tool_choice` (V1ResponsesPostRequestBodyContentApplicationJsonSchemaToolChoice, optional) — 控制模型可以、必须或不得调用工具。请用你的模型测试你依赖的取值。

## Response

### 200

非流式调用返回一个 JSON 对象。以下是精简后的示例。

- `id` (string, optional) — 响应 ID。请连同请求 ID 一起记录，方便售后和对账。
- `model` (string, optional) — 实际作答的模型。
- `status` (string, optional) — `completed` 表示作答完成。
- `output` (list of V1ResponsesPostResponsesContentApplicationJsonSchemaOutputItems, optional) — 输出项：`message`、`reasoning` 和 `function_call`。SDK 的 `output_text` 会帮你拼接其中的文本片段。
- `usage` (V1ResponsesPostResponsesContentApplicationJsonSchemaUsage, optional) — token 数量。调用按实际 token 用量计量。

## 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` 退避后重试一两次。 认证、路由、限速和未知模型这几类失败发生在调用模型之前，返回 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

### V1ResponsesPostRequestBodyContentApplicationJsonSchemaInput

提示词：可以是字符串，也可以是输入项数组，例如消息、函数调用及其输出。 服务端不保存会话状态。不支持 `previous_response_id`、`conversation`、`prompt` 和 `context_management`：每一轮都要把完整历史放进 `input`。

### V1ResponsesPostRequestBodyContentApplicationJsonSchemaToolsItems

### V1ResponsesPostRequestBodyContentApplicationJsonSchemaToolChoice

控制模型可以、必须或不得调用工具。请用你的模型测试你依赖的取值。

### V1ResponsesPostResponsesContentApplicationJsonSchemaOutputItems

- `content` (list of V1ResponsesPostResponsesContentApplicationJsonSchemaOutputItemsContentItems, optional)

### V1ResponsesPostResponsesContentApplicationJsonSchemaUsage

token 数量。调用按实际 token 用量计量。

### V1ResponsesPostResponsesContentApplicationJsonSchemaOutputItemsContentItems

- `text` (string, optional) — `message` 输出项的答案文本，位于类型为 `output_text` 的片段里。

## Examples

**Request**

```json
{
  "model": "MiniMax-M3",
  "input": "Design a resilient webhook retry strategy for a payments API.",
  "max_output_tokens": 2000
}
```

**Response**

```json
{
  "id": "resp_example",
  "model": "MiniMax-M3",
  "status": "completed",
  "output": [
    {
      "content": [
        {
          "text": "Retry with exponential backoff and jitter, and make every handler idempotent.",
          "type": "output_text"
        }
      ],
      "role": "assistant",
      "type": "message"
    }
  ],
  "usage": {
    "input_tokens": 19,
    "output_tokens": 16,
    "total_tokens": 35
  },
  "object": "response"
}
```

**SDK Code**

```python 快速开始
import requests

url = "https://direct.beatapi.io/v1/responses"

payload = {
    "model": "MiniMax-M3",
    "input": "Design a resilient webhook retry strategy for a payments API.",
    "max_output_tokens": 2000
}
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/responses';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"MiniMax-M3","input":"Design a resilient webhook retry strategy for a payments API.","max_output_tokens":2000}'
};

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/responses"

	payload := strings.NewReader("{\n  \"model\": \"MiniMax-M3\",\n  \"input\": \"Design a resilient webhook retry strategy for a payments API.\",\n  \"max_output_tokens\": 2000\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/responses")

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\": \"MiniMax-M3\",\n  \"input\": \"Design a resilient webhook retry strategy for a payments API.\",\n  \"max_output_tokens\": 2000\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/responses")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"MiniMax-M3\",\n  \"input\": \"Design a resilient webhook retry strategy for a payments API.\",\n  \"max_output_tokens\": 2000\n}")
  .asString();
```

```php 快速开始
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://direct.beatapi.io/v1/responses', [
  'body' => '{
  "model": "MiniMax-M3",
  "input": "Design a resilient webhook retry strategy for a payments API.",
  "max_output_tokens": 2000
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp 快速开始
using RestSharp;

var client = new RestClient("https://direct.beatapi.io/v1/responses");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"MiniMax-M3\",\n  \"input\": \"Design a resilient webhook retry strategy for a payments API.\",\n  \"max_output_tokens\": 2000\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 快速开始
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "MiniMax-M3",
  "input": "Design a resilient webhook retry strategy for a payments API.",
  "max_output_tokens": 2000
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://direct.beatapi.io/v1/responses")! 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()
```