Đối với hầu hết các tích hợp mới, bắt đầu với Chat Completions qua POST /v1/chat/completions.
curl https://api.tokenlab.sh/v1/chat/completions \ -H "Authorization: Bearer sk-your-api-key" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.4", "messages": [ {"role": "user", "content": "What is the capital of France?"} ] }'
from openai import OpenAIclient = OpenAI( api_key="sk-your-api-key", base_url="https://api.tokenlab.sh/v1")response = client.chat.completions.create( model="gpt-5.4", messages=[{"role": "user", "content": "What is the capital of France?"}])print(response.choices[0].message.content)
import OpenAI from 'openai';const client = new OpenAI({ apiKey: 'sk-your-api-key', baseURL: 'https://api.tokenlab.sh/v1'});const response = await client.chat.completions.create({ model: 'gpt-5.4', messages: [{ role: 'user', content: 'What is the capital of France?' }],});console.log(response.choices[0].message.content);
Chỉ sử dụng POST /v1/responses khi bạn thực sự cần hành vi đặc thù của Responses. Một số trường chỉ dành cho Responses phụ thuộc vào model được chọn và đường dẫn được định tuyến.
Credits dùng thử được tặng dành cho các kiểm thử nhỏ đầu tiên. Chỉ thêm credits trong Dashboard → Billing khi bạn đã sẵn sàng dùng production hoặc kiểm thử với lưu lượng cao hơn.
stream = client.chat.completions.create( model="gpt-5.4", messages=[{"role": "user", "content": "Tell me a short story."}], stream=True)for chunk in stream: delta = chunk.choices[0].delta.content if delta: print(delta, end="")