> ## Documentation Index
> Fetch the complete documentation index at: https://docs.playapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# HTTP and cURL

> Send JSON requests directly and read the results.

Requires cURL 7.76+ and Bash / Zsh. Set the [environment variables](/en/guides/api-basics) first.

## Chat Completions

Save the following as `request.json`, replacing `YOUR_MODEL_ID` with an actual chat model ID:

```json theme={null}
{
  "model": "YOUR_MODEL_ID",
  "messages": [{ "role": "user", "content": "Say hello in one short sentence." }]
}
```

```bash theme={null}
curl --fail-with-body --silent --show-error --max-time 60 \
  "$API_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  --data-binary @request.json
```

Read `choices[0].message.content` on success. Text may be empty for tool calls; inspect `tool_calls` and `finish_reason` as well.

## Responses

Confirm Responses support, replace `request.json` with the following content, and call `/responses`:

```json theme={null}
{
  "model": "YOUR_MODEL_ID",
  "input": "Say hello in one short sentence."
}
```

```bash theme={null}
curl --fail-with-body --silent --show-error --max-time 60 \
  "$API_BASE_URL/responses" \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  --data-binary @request.json
```

Check `status` first. Find items with `type=message` in `output`, then read `text` from their `content` entries with `type=output_text`. Raw HTTP JSON does not guarantee a top-level `output_text`; the SDK provides that convenience property.

## Requests and results

`--fail-with-body` preserves the response body and exits with a nonzero status on HTTP errors. `--max-time 60` is this example's client timeout, not a server processing deadline. A timeout does not prove that the upstream did not execute the request; avoid immediately resubmitting it.

For streaming, add `"stream": true` to the JSON and `--no-buffer` to cURL. Handle [SSE events](/en/guides/streaming) instead of parsing the whole response as JSON.

[Investigate errors](/en/guides/errors)

[简体中文](/zh/guides/http)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.