# curl

Source: https://staging-docs.aiand.com/sdks/curl/

Every ai& endpoint is just HTTP + JSON. Use `curl` to test from a shell, automate from CI, or sanity-check before reaching for an SDK.

## Authentication

```bash
export AIAND_API_KEY="sk-your-aiand-api-key"
```

## Chat completion

```bash
curl https://api.aiand.com/v1/chat/completions \
  -H "Authorization: Bearer $AIAND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "...",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
```

## Streaming

Add `"stream": true` and use `curl -N` to disable buffering:

```bash
curl -N https://api.aiand.com/v1/chat/completions \
  -H "Authorization: Bearer $AIAND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "...",
    "stream": true,
    "messages": [{"role": "user", "content": "Hello"}]
  }'
```

## Vision (file_id)

```bash
curl https://api.aiand.com/v1/chat/completions \
  -H "Authorization: Bearer $AIAND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "...",
    "messages": [{
      "role": "user",
      "content": [
        {"type": "text", "text": "What is this?"},
        {"type": "file", "file": {"file_id": "file-abc123"}}
      ]
    }]
  }'
```

## File upload

```bash
curl https://api.aiand.com/v1/files \
  -H "Authorization: Bearer $AIAND_API_KEY" \
  -F "file=@cat.png" \
  -F "purpose=vision"
```

## Anthropic shape

Add `-H "anthropic-version: 2023-06-01"` and hit `/v1/messages` instead. See [Messages](/api/messages/).
