Bước 1: Lấy API Key của bạn
Nạp credit
Đi tới dashboard và nạp credit vào tài khoản của bạn. Mô hình thanh toán pay-as-you-go không yêu cầu mức tối thiểu.
Tạo API key
Đi tới Dashboard → API Keys và tạo một key mới. Hãy sao chép và lưu trữ bảo mật - nó chỉ được hiển thị một lần duy nhất.
Giữ API key của bạn an toàn. Tuyệt đối không để lộ trong mã nguồn phía client hoặc các kho lưu trữ công khai.
Bước 2: Cài đặt SDK
Bước 3: Thực hiện yêu cầu đầu tiên
cURL
Python
JavaScript
Go
PHP
curl https://api.lemondata.cc/v1/chat/completions \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
]
}'
Thử các Model khác nhau
LemonData hỗ trợ hơn 300 model. Chỉ cần thay đổi tham số model:
# OpenAI GPT-4o
response = client.chat.completions.create( model = "gpt-4o" , messages = messages)
# Anthropic Claude Sonnet 4.5
response = client.chat.completions.create( model = "claude-sonnet-4-5" , messages = messages)
# Google Gemini 2.5 Flash
response = client.chat.completions.create( model = "gemini-2.5-flash" , messages = messages)
# DeepSeek R1
response = client.chat.completions.create( model = "deepseek-r1" , messages = messages)
Bật Streaming
Để nhận phản hồi theo thời gian thực, hãy bật tính năng streaming:
stream = client.chat.completions.create(
model = "gpt-4o" ,
messages = [{ "role" : "user" , "content" : "Tell me a story" }],
stream = True
)
for chunk in stream:
if chunk.choices[ 0 ].delta.content:
print (chunk.choices[ 0 ].delta.content, end = "" )
Tiếp theo là gì?