# curl

> Call the SrotGateway API from the command line with curl: chat completions, streaming and the model list, with copy-ready examples.

Source: https://srotgateway.com/docs/curl/

```bash
export SROT_API_KEY="sg-..."
```

## List models

```bash
curl https://api.srotgateway.com/v1/models
```

## Chat

```bash
curl https://api.srotgateway.com/v1/chat/completions \
  -H "Authorization: Bearer $SROT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash-fast",
    "messages": [{"role": "user", "content": "What is an API?"}],
    "max_tokens": 300
  }'
```

## Streaming

Add `"stream": true` and `-N` so curl prints each piece as it arrives:

```bash
curl -N https://api.srotgateway.com/v1/chat/completions \
  -H "Authorization: Bearer $SROT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek-v4.1-flash-fast", "stream": true, "messages": [{"role": "user", "content": "Count to 20"}]}'
```

Each line starts with `data: ` and holds one JSON piece. The stream ends with `data: [DONE]`.
