cURL
cURL, SDK kurmadan API’yi denemek için en hızlı yol.
Chat Completions
Section titled “Chat Completions”curl https://llmtr.com/v1/chat/completions \ -H "Authorization: Bearer sk_your_key" \ -H "Content-Type: application/json" \ -d '{ "model": "openai/gpt-4o", "messages": [ {"role": "user", "content": "Hello!"} ] }'Streaming
Section titled “Streaming”curl -N https://llmtr.com/v1/chat/completions \ -H "Authorization: Bearer sk_your_key" \ -H "Content-Type: application/json" \ -d '{ "model": "openai/gpt-4o", "messages": [{"role": "user", "content": "Count to 5"}], "stream": true }'-N flag’i buffering’i kapatır, SSE chunk’ları gelir gelmez yazdırır.
Dosya yükleme
Section titled “Dosya yükleme”curl https://llmtr.com/v1/files \ -H "Authorization: Bearer sk_your_key" \ -F "provider=google" \ -F "purpose=user_upload" \ -F "file=@./document.pdf"Environment variable ile
Section titled “Environment variable ile”Anahtarı inline yazmak yerine env var kullanın:
export LLMTR_API_KEY="sk_your_key"
curl https://llmtr.com/v1/chat/completions \ -H "Authorization: Bearer $LLMTR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"openai/gpt-4o","messages":[{"role":"user","content":"Hi"}]}'Yanıt formatlama
Section titled “Yanıt formatlama”JSON çıktısını jq ile okunabilir hale getirin:
curl ... | jq '.choices[0].message.content'