# curl (/vi/docs/guides/curl)

Gọi mọi endpoint từ dòng lệnh.



Đặt key của bạn một lần:

```bash title="Terminal"
export CHEAPAIMODEL_API_KEY="sk-..."
```

## Liệt kê mô hình [#list-models]

```bash
curl https://api.cheapaimodel.ai/v1/models \
  -H "Authorization: Bearer $CHEAPAIMODEL_API_KEY"
```

## Chat completion [#chat-completion]

```bash
curl https://api.cheapaimodel.ai/v1/chat/completions \
  -H "Authorization: Bearer $CHEAPAIMODEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek-v4-1-flash", "messages": [{"role": "user", "content": "Hello!"}]}'
```

Thêm `"stream": true` và truyền `-N` cho curl để thấy token hiện ra ngay khi tới.

## Response [#response]

```bash
curl https://api.cheapaimodel.ai/v1/responses \
  -H "Authorization: Bearer $CHEAPAIMODEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek-v4-1-flash", "input": "Hello!"}'
```

## Message (định dạng Anthropic) [#message-anthropic-format]

Hiện chưa có mô hình nào trong [danh mục](/vi/models) liệt kê `/v1/messages`. Yêu cầu dưới đây chỉ minh họa cấu trúc; thay `<model-id>` bằng một mô hình có trang danh mục liệt kê endpoint này.

```bash
curl https://api.cheapaimodel.ai/v1/messages \
  -H "x-api-key: $CHEAPAIMODEL_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model": "<model-id>", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello!"}]}'
```

## Embeddings [#embeddings]

Hiện chưa có mô hình nào trong [danh mục](/vi/models) liệt kê `/v1/embeddings`. Yêu cầu dưới đây chỉ minh họa cấu trúc; thay `<model-id>` bằng một mô hình có trang danh mục liệt kê endpoint này.

```bash
curl https://api.cheapaimodel.ai/v1/embeddings \
  -H "Authorization: Bearer $CHEAPAIMODEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "<model-id>", "input": "The quick brown fox"}'
```
