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

# Run a capability, poll a task or fetch a result

POST https://api.beatapi.io/v1/capabilities/run
Content-Type: application/json

Runs an inspected capability with your API key; a start spends balance at the
inspected price. Copy `next` from Inspect and fill the placeholders.

* `operation: start` (default): `input` follows the inspected `input_schema`;
  unknown fields inside `input` are rejected. Synchronous kinds — social and web
  data, text models, JEV — return the result in the response. Asynchronous
  kinds — image, video, workflows and `data:web.research` (30 s to 3 min) —
  return `{data: task, next}`; repeat `next`, an `operation: status` call with
  `task_id`, until `succeeded` or `failed`. A finished research task carries its
  result in `data.output`; a failed one is not charged.
* Text models: `{"reference":"model:<id>","input":{"input":"<prompt>"}}` returns
  `{object:"text.result", model, status, output_text, usage, request_id}`.
  `input.input` is a string or a messages array; `instructions`,
  `max_output_tokens` and `temperature` are optional.
* JEV (`model:jev-1.13`, `model:jev-1.13-free`): `{"input":{"state":…,"questions":…}}`
  returns `{id, model, answers, usage}`.
* Result views: `view: preview` lifts the result's main list to `items` (the
  first `max_items`, default 10, each element trimmed inside) with `items_path`
  and `items_total`, shortens long strings and marks the reply `truncated` with
  a `result_ref`; `fields` keeps only the listed paths, `items[].<key>` for keys
  of each list element. REST defaults to `full`; the BeatAPI MCP server
  defaults to `preview`. A status poll takes the same view.
* `operation: result` with `request_id` returns a finished result again, free,
  for one hour, with any `view`, `fields` or `max_items`.

Send a unique `idempotency_key` per task as a top-level field (or the
`Idempotency-Key` header) and reuse it only to retry the same start. An unknown reference returns `404` with
`suggestions`.

Reference: https://docs.beatapi.io/api-reference/core/capabilities/run-capability

## Authentication

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

## Request

### Headers

- `X-Beat-Client` (enum, optional, default: http) — Dialect of `next`: `http` (default) writes a curl command, `mcp` writes a capabilities tool call. The BeatAPI MCP server sends `mcp`.
  - Allowed values: `http`, `mcp`

### Body (application/json)

This endpoint expects a CapabilityRunRequest.

- `reference` (string, required) — The inspected reference
- `operation` (enum, optional, default: start) — `start`: run it. `status`: poll an async task (needs `task_id`; takes `view`, `max_items` and `fields` like start). `result`: fetch a finished result again, free within one hour (needs `request_id`).
  - Allowed values: `start`, `status`, `result`
- `input` (map from string to any, optional) — For start: the input, following the inspected `input_schema`. Text models: `{"input": "<prompt or messages>"}` with optional `instructions`, `max_output_tokens`, `temperature`. JEV: `{"state": …, "questions": …}`.
- `task_id` (string, optional) — For status: the task id an async start returned.
- `request_id` (string, optional) — For result: the `request_id` a sync start returned.
- `view` (enum, optional) — `full` (REST default): the whole result. `preview`: the result's main list lifted to `items` (the first `max_items` elements, each trimmed inside) with `items_path` and `items_total`, long strings shortened, `truncated` and `result_ref` reported.
  - Allowed values: `full`, `preview`
- `max_items` (integer, optional) — With `preview`: elements kept in `items` (default 10).
- `fields` (list of string, optional) — Keep only these paths. Paths starting `items[]` are read from each element of the result's list and returned as `items`, such as `items[].title`; other paths are dotted from the root, `[]` walks an array.
- `idempotency_key` (string, optional) — Unique per task, a top-level field next to `reference` and `input` (or the `Idempotency-Key` header); reuse only to retry the same start.

## Response

### 200

Synchronous result, stored result or task status

- `object` (string, optional)
- `id` (string, optional) — Task id for async kinds.
- `status` (string, optional) — Task status: poll until `succeeded` or `failed`.
- `request_id` (string, optional) — Pass to `operation: result` to fetch the stored result.
- `output_text` (string, optional) — Text models only.
- `answers` (map from string to any, optional) — JEV only.
- `items` (list of any, optional) — With `preview` or `items[]` fields: the elements of the result's main list.
- `items_path` (string, optional) — Where the list sits in the full result, such as `data.data.items` or `results`.
- `items_total` (integer, optional) — Elements in the full list.
- `items_shown` (integer, optional) — Elements in `items`.
- `truncated` (boolean, optional) — True when a preview cut the result.
- `result_ref` (CapabilityRunResultResultRef, optional) — The stored full result, when a view left anything out.
- `usage` (map from string to any, optional)
- `data` (any, optional) — The result payload or the wrapped object.

### 201

Accepted asynchronous task; poll it with operation status

- `object` (string, optional)
- `id` (string, optional) — Task id for async kinds.
- `status` (string, optional) — Task status: poll until `succeeded` or `failed`.
- `request_id` (string, optional) — Pass to `operation: result` to fetch the stored result.
- `output_text` (string, optional) — Text models only.
- `answers` (map from string to any, optional) — JEV only.
- `items` (list of any, optional) — With `preview` or `items[]` fields: the elements of the result's main list.
- `items_path` (string, optional) — Where the list sits in the full result, such as `data.data.items` or `results`.
- `items_total` (integer, optional) — Elements in the full list.
- `items_shown` (integer, optional) — Elements in `items`.
- `truncated` (boolean, optional) — True when a preview cut the result.
- `result_ref` (CapabilityRunResultResultRef, optional) — The stored full result, when a view left anything out.
- `usage` (map from string to any, optional)
- `data` (any, optional) — The result payload or the wrapped object.

## Errors

### 400 Bad Request Error

Malformed JSON or a field, value or combination this endpoint does not accept (`bad_request`; the message names the field), or input refused by moderation (`content_policy_violation`). Not retryable unchanged.

- `error` (ErrorError, required) — Structured BeatAPI error. Use `code` (or `retryable`) for program logic and retain `request_id` for support.

### 401 Unauthorized Error

No API key (`missing_api_key`), or a key that is wrong, expired, disabled or exhausted (`invalid_api_key`; the message says which). Send it as `Authorization: Bearer <key>`; the key works with or without the `sk-` prefix. Not retryable.

- `error` (ErrorError, required) — Structured BeatAPI error. Use `code` (or `retryable`) for program logic and retain `request_id` for support.

### 402 Payment Required Error

Insufficient balance (`insufficient_credits`). The account balance is zero or below the price of this request. Top up, then send it again; not retryable before that.

- `error` (ErrorError, required) — Structured BeatAPI error. Use `code` (or `retryable`) for program logic and retain `request_id` for support.

### 403 Forbidden Error

The key or account is not permitted to make this call (`forbidden`), for example a model that is not available on free credit (a top-up unlocks it), a request from outside the key's IP allowlist, or a model outside the key's group. Not retryable.

- `error` (ErrorError, required) — Structured BeatAPI error. Use `code` (or `retryable`) for program logic and retain `request_id` for support.

### 404 Not Found Error

Unknown capability reference. `suggestions` lists the closest published references and `next` inspects the best of them.

- `error` (V1CapabilitiesRunPostResponsesContentApplicationJsonSchemaError, required)

### 409 Conflict Error

The `Idempotency-Key` was already used with a different request body, or the first request with it is still being processed (`idempotency_conflict`). Not retryable unchanged.

- `error` (ErrorError, required) — Structured BeatAPI error. Use `code` (or `retryable`) for program logic and retain `request_id` for support.

### 429 Too Many Requests Error

Too many requests (`rate_limit_exceeded`, including the free-model limits) or too many tasks processing at once (`user_concurrency_exceeded`). Retryable after `Retry-After` seconds (also `error.retry_after_seconds`).

- `error` (ErrorError, required) — Structured BeatAPI error. Use `code` (or `retryable`) for program logic and retain `request_id` for support.

### 500 Internal Server Error

Unexpected internal error (`internal_error`). Retryable; keep `request_id` for support if it persists.

- `error` (ErrorError, required) — Structured BeatAPI error. Use `code` (or `retryable`) for program logic and retain `request_id` for support.

### 503 Service Unavailable Error

The request could not be completed (`processing_unavailable`, `processing_timeout`, `processing_failed` or `result_transfer_failed`). Nothing was charged. Retryable with backoff; `Retry-After` is sent when the wait is known. BeatAPI does not answer 502 or 504.

- `error` (ErrorError, required) — Structured BeatAPI error. Use `code` (or `retryable`) for program logic and retain `request_id` for support.

## Types

### CapabilityRunResultResultRef

The stored full result, when a view left anything out.

- `request_id` (string, optional) — Pass to `operation: result`.
- `expires_at` (datetime, optional)

### ErrorError

Structured BeatAPI error. Use `code` (or `retryable`) for program logic and retain `request_id` for support.

- `code` (enum, required) — Stable machine-readable error code. `unauthorized` is the deprecated name for a 401; since 2026-09-29 a 401 is `missing_api_key` or `invalid_api_key`. Treat a legacy `unauthorized` like `invalid_api_key`.
  - Allowed values: `bad_request`, `missing_api_key`, `invalid_api_key`, `unauthorized`, `forbidden`, `not_found`, `insufficient_credits`, `idempotency_conflict`, `user_concurrency_exceeded`, `rate_limit_exceeded`, `content_policy_violation`, `processing_unavailable`, `processing_failed`, `processing_timeout`, `result_transfer_failed`, `invalid_signature`, `realtime_disabled`, `realtime_capacity_unavailable`, `realtime_session_expired`, `origin_not_allowed`, `invalid_client_secret`, `transport_not_allowed`, `internal_error`
- `message` (string, required) — English sentence that states the cause; for `bad_request` it names the field. Written for people and logs, not for parsing.
- `retryable` (boolean, required) — Whether making the same call again could succeed. Present on every error; branch on it instead of the status code. True for 429, 500 and 503 (rate_limit_exceeded, user_concurrency_exceeded, internal_error, processing_unavailable, processing_timeout, processing_failed, result_transfer_failed, realtime_capacity_unavailable). False for a request, key or balance that must change first (bad_request, content_policy_violation, missing_api_key, invalid_api_key, insufficient_credits, forbidden, not_found, idempotency_conflict, realtime_disabled and the other realtime credential codes).
- `request_id` (string, required) — Correlation ID to retain for BeatAPI support.
- `retry_after_seconds` (integer, optional) — Seconds to wait before retrying. Present on every 429, and on a 503 when the wait is known; the same value is sent in the `Retry-After` header.
- `docs` (string, optional) — The public Skill page that says what to do about an error. Present on errors answered by the capability endpoints (`/v1/capabilities/search`, `/v1/capabilities/inspect`, `/v1/capabilities/run`); absent on every other endpoint.

### V1CapabilitiesRunPostResponsesContentApplicationJsonSchemaError

- `code` (enum, required)
  - Allowed values: `not_found`
- `message` (string, required)
- `retryable` (boolean, required)
- `request_id` (string, required)
- `suggestions` (list of string, optional)
- `next` (CapabilityNext, optional) — The call to make next, in the caller's dialect: an MCP tool call `{tool, arguments}` when the request sent `X-Beat-Client: mcp`, otherwise a complete curl command. Copy it and replace the `<placeholders>`.

### CapabilityNext

The call to make next, in the caller's dialect: an MCP tool call `{tool, arguments}` when the request sent `X-Beat-Client: mcp`, otherwise a complete curl command. Copy it and replace the `<placeholders>`.

- `action` (enum, required)
  - Allowed values: `search`, `inspect`, `run`, `status`, `result`, `none`
- `call` (CapabilityNextCall, optional)
- `note` (string, optional)

### CapabilityNextCall

### CapabilityNextCall1

- `tool` (enum, required)
  - Allowed values: `capabilities_search`, `capabilities_inspect`, `capabilities_run`
- `arguments` (map from string to any, required)

## Examples

### Social data, preview

**Request**

```json
{
  "reference": "data:xiaohongshu.app_v2.search_notes",
  "input": {
    "keyword": "AI 视频"
  },
  "view": "preview"
}
```

**Response**

```json
{
  "object": "string",
  "id": "string",
  "status": "string",
  "request_id": "string",
  "output_text": "string",
  "answers": {},
  "items": [
    null
  ],
  "items_path": "string",
  "items_total": 1,
  "items_shown": 1,
  "truncated": true,
  "result_ref": {
    "request_id": "string",
    "expires_at": "2024-01-15T09:30:00Z"
  },
  "usage": {},
  "data": null
}
```

**SDK Code**

```python Social data, preview
import requests

url = "https://api.beatapi.io/v1/capabilities/run"

payload = {
    "reference": "data:xiaohongshu.app_v2.search_notes",
    "input": { "keyword": "AI 视频" },
    "view": "preview"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Social data, preview
const url = 'https://api.beatapi.io/v1/capabilities/run';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"reference":"data:xiaohongshu.app_v2.search_notes","input":{"keyword":"AI 视频"},"view":"preview"}'
};

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

```go Social data, preview
package main

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

func main() {

	url := "https://api.beatapi.io/v1/capabilities/run"

	payload := strings.NewReader("{\n  \"reference\": \"data:xiaohongshu.app_v2.search_notes\",\n  \"input\": {\n    \"keyword\": \"AI 视频\"\n  },\n  \"view\": \"preview\"\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 Social data, preview
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/capabilities/run")

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  \"reference\": \"data:xiaohongshu.app_v2.search_notes\",\n  \"input\": {\n    \"keyword\": \"AI 视频\"\n  },\n  \"view\": \"preview\"\n}"

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

```java Social data, preview
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/capabilities/run")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"reference\": \"data:xiaohongshu.app_v2.search_notes\",\n  \"input\": {\n    \"keyword\": \"AI 视频\"\n  },\n  \"view\": \"preview\"\n}")
  .asString();
```

```php Social data, preview
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/capabilities/run', [
  'body' => '{
  "reference": "data:xiaohongshu.app_v2.search_notes",
  "input": {
    "keyword": "AI 视频"
  },
  "view": "preview"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Social data, preview
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/capabilities/run");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"reference\": \"data:xiaohongshu.app_v2.search_notes\",\n  \"input\": {\n    \"keyword\": \"AI 视频\"\n  },\n  \"view\": \"preview\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Social data, preview
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "reference": "data:xiaohongshu.app_v2.search_notes",
  "input": ["keyword": "AI 视频"],
  "view": "preview"
] as [String : Any]

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

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

### Social data, preview

**Request**

```json
{
  "reference": "data:xiaohongshu.app_v2.search_notes",
  "input": {
    "keyword": "AI 视频"
  },
  "view": "preview"
}
```

**Response**

```json
{
  "object": "string",
  "id": "string",
  "status": "string",
  "request_id": "string",
  "output_text": "string",
  "answers": {},
  "items": [
    null
  ],
  "items_path": "string",
  "items_total": 1,
  "items_shown": 1,
  "truncated": true,
  "result_ref": {
    "request_id": "string",
    "expires_at": "2024-01-15T09:30:00Z"
  },
  "usage": {},
  "data": null
}
```

**SDK Code**

```python Social data, preview
import requests

url = "https://api.beatapi.io/v1/capabilities/run"

payload = {
    "reference": "data:xiaohongshu.app_v2.search_notes",
    "input": { "keyword": "AI 视频" },
    "view": "preview"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Social data, preview
const url = 'https://api.beatapi.io/v1/capabilities/run';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"reference":"data:xiaohongshu.app_v2.search_notes","input":{"keyword":"AI 视频"},"view":"preview"}'
};

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

```go Social data, preview
package main

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

func main() {

	url := "https://api.beatapi.io/v1/capabilities/run"

	payload := strings.NewReader("{\n  \"reference\": \"data:xiaohongshu.app_v2.search_notes\",\n  \"input\": {\n    \"keyword\": \"AI 视频\"\n  },\n  \"view\": \"preview\"\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 Social data, preview
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/capabilities/run")

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  \"reference\": \"data:xiaohongshu.app_v2.search_notes\",\n  \"input\": {\n    \"keyword\": \"AI 视频\"\n  },\n  \"view\": \"preview\"\n}"

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

```java Social data, preview
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/capabilities/run")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"reference\": \"data:xiaohongshu.app_v2.search_notes\",\n  \"input\": {\n    \"keyword\": \"AI 视频\"\n  },\n  \"view\": \"preview\"\n}")
  .asString();
```

```php Social data, preview
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/capabilities/run', [
  'body' => '{
  "reference": "data:xiaohongshu.app_v2.search_notes",
  "input": {
    "keyword": "AI 视频"
  },
  "view": "preview"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Social data, preview
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/capabilities/run");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"reference\": \"data:xiaohongshu.app_v2.search_notes\",\n  \"input\": {\n    \"keyword\": \"AI 视频\"\n  },\n  \"view\": \"preview\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Social data, preview
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "reference": "data:xiaohongshu.app_v2.search_notes",
  "input": ["keyword": "AI 视频"],
  "view": "preview"
] as [String : Any]

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

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

### Text model

**Request**

```json
{
  "reference": "model:<text model id>",
  "input": {
    "input": "Summarise this in one sentence."
  }
}
```

**Response**

```json
{
  "object": "string",
  "id": "string",
  "status": "string",
  "request_id": "string",
  "output_text": "string",
  "answers": {},
  "items": [
    null
  ],
  "items_path": "string",
  "items_total": 1,
  "items_shown": 1,
  "truncated": true,
  "result_ref": {
    "request_id": "string",
    "expires_at": "2024-01-15T09:30:00Z"
  },
  "usage": {},
  "data": null
}
```

**SDK Code**

```python Text model
import requests

url = "https://api.beatapi.io/v1/capabilities/run"

payload = {
    "reference": "model:<text model id>",
    "input": { "input": "Summarise this in one sentence." }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Text model
const url = 'https://api.beatapi.io/v1/capabilities/run';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"reference":"model:<text model id>","input":{"input":"Summarise this in one sentence."}}'
};

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

```go Text model
package main

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

func main() {

	url := "https://api.beatapi.io/v1/capabilities/run"

	payload := strings.NewReader("{\n  \"reference\": \"model:<text model id>\",\n  \"input\": {\n    \"input\": \"Summarise this in one sentence.\"\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 Text model
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/capabilities/run")

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  \"reference\": \"model:<text model id>\",\n  \"input\": {\n    \"input\": \"Summarise this in one sentence.\"\n  }\n}"

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

```java Text model
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/capabilities/run")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"reference\": \"model:<text model id>\",\n  \"input\": {\n    \"input\": \"Summarise this in one sentence.\"\n  }\n}")
  .asString();
```

```php Text model
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/capabilities/run', [
  'body' => '{
  "reference": "model:<text model id>",
  "input": {
    "input": "Summarise this in one sentence."
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Text model
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/capabilities/run");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"reference\": \"model:<text model id>\",\n  \"input\": {\n    \"input\": \"Summarise this in one sentence.\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Text model
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "reference": "model:<text model id>",
  "input": ["input": "Summarise this in one sentence."]
] as [String : Any]

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

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

### Poll an async task

**Request**

```json
{
  "reference": "<same reference>",
  "operation": "status",
  "task_id": "<task id>"
}
```

**Response**

```json
{
  "object": "string",
  "id": "string",
  "status": "string",
  "request_id": "string",
  "output_text": "string",
  "answers": {},
  "items": [
    null
  ],
  "items_path": "string",
  "items_total": 1,
  "items_shown": 1,
  "truncated": true,
  "result_ref": {
    "request_id": "string",
    "expires_at": "2024-01-15T09:30:00Z"
  },
  "usage": {},
  "data": null
}
```

**SDK Code**

```python Poll an async task
import requests

url = "https://api.beatapi.io/v1/capabilities/run"

payload = {
    "reference": "<same reference>",
    "operation": "status",
    "task_id": "<task id>"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Poll an async task
const url = 'https://api.beatapi.io/v1/capabilities/run';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"reference":"<same reference>","operation":"status","task_id":"<task id>"}'
};

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

```go Poll an async task
package main

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

func main() {

	url := "https://api.beatapi.io/v1/capabilities/run"

	payload := strings.NewReader("{\n  \"reference\": \"<same reference>\",\n  \"operation\": \"status\",\n  \"task_id\": \"<task id>\"\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 Poll an async task
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/capabilities/run")

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  \"reference\": \"<same reference>\",\n  \"operation\": \"status\",\n  \"task_id\": \"<task id>\"\n}"

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

```java Poll an async task
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/capabilities/run")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"reference\": \"<same reference>\",\n  \"operation\": \"status\",\n  \"task_id\": \"<task id>\"\n}")
  .asString();
```

```php Poll an async task
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/capabilities/run', [
  'body' => '{
  "reference": "<same reference>",
  "operation": "status",
  "task_id": "<task id>"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Poll an async task
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/capabilities/run");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"reference\": \"<same reference>\",\n  \"operation\": \"status\",\n  \"task_id\": \"<task id>\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Poll an async task
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "reference": "<same reference>",
  "operation": "status",
  "task_id": "<task id>"
] as [String : Any]

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

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

### Fetch a stored result

**Request**

```json
{
  "reference": "<same reference>",
  "operation": "result",
  "request_id": "<request id>",
  "fields": [
    "data.items[].title"
  ]
}
```

**Response**

```json
{
  "object": "string",
  "id": "string",
  "status": "string",
  "request_id": "string",
  "output_text": "string",
  "answers": {},
  "items": [
    null
  ],
  "items_path": "string",
  "items_total": 1,
  "items_shown": 1,
  "truncated": true,
  "result_ref": {
    "request_id": "string",
    "expires_at": "2024-01-15T09:30:00Z"
  },
  "usage": {},
  "data": null
}
```

**SDK Code**

```python Fetch a stored result
import requests

url = "https://api.beatapi.io/v1/capabilities/run"

payload = {
    "reference": "<same reference>",
    "operation": "result",
    "request_id": "<request id>",
    "fields": ["data.items[].title"]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Fetch a stored result
const url = 'https://api.beatapi.io/v1/capabilities/run';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"reference":"<same reference>","operation":"result","request_id":"<request id>","fields":["data.items[].title"]}'
};

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

```go Fetch a stored result
package main

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

func main() {

	url := "https://api.beatapi.io/v1/capabilities/run"

	payload := strings.NewReader("{\n  \"reference\": \"<same reference>\",\n  \"operation\": \"result\",\n  \"request_id\": \"<request id>\",\n  \"fields\": [\n    \"data.items[].title\"\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 Fetch a stored result
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/capabilities/run")

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  \"reference\": \"<same reference>\",\n  \"operation\": \"result\",\n  \"request_id\": \"<request id>\",\n  \"fields\": [\n    \"data.items[].title\"\n  ]\n}"

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

```java Fetch a stored result
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/capabilities/run")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"reference\": \"<same reference>\",\n  \"operation\": \"result\",\n  \"request_id\": \"<request id>\",\n  \"fields\": [\n    \"data.items[].title\"\n  ]\n}")
  .asString();
```

```php Fetch a stored result
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/capabilities/run', [
  'body' => '{
  "reference": "<same reference>",
  "operation": "result",
  "request_id": "<request id>",
  "fields": [
    "data.items[].title"
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Fetch a stored result
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/capabilities/run");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"reference\": \"<same reference>\",\n  \"operation\": \"result\",\n  \"request_id\": \"<request id>\",\n  \"fields\": [\n    \"data.items[].title\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Fetch a stored result
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "reference": "<same reference>",
  "operation": "result",
  "request_id": "<request id>",
  "fields": ["data.items[].title"]
] as [String : Any]

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

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