cheapaimodel

curl

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

Sao chép

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

Terminal
export CHEAPAIMODEL_API_KEY="sk-..."

Liệt kê mô hình

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

Chat completion

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

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)

Hiện chưa có mô hình nào trong danh mục 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.

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

Hiện chưa có mô hình nào trong danh mục 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.

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"}'