İçeriğe geç

cURL

cURL, SDK kurmadan API’yi denemek için en hızlı yol.

Terminal window
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!"}
]
}'
Terminal window
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.

Terminal window
curl https://llmtr.com/v1/files \
-H "Authorization: Bearer sk_your_key" \
-F "provider=google" \
-F "purpose=user_upload" \
-F "file=@./document.pdf"

Anahtarı inline yazmak yerine env var kullanın:

Terminal window
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"}]}'

JSON çıktısını jq ile okunabilir hale getirin:

Terminal window
curl ... | jq '.choices[0].message.content'