Using the API with cURL
Direct API calls from the terminal
cURL is a powerful tool that lets you send HTTP requests from the command line. It is the simplest way to test and integrate the Onysoft API.
Basic Request
The example below sends a simple chat completion request:
cURL
curl https://api.onysoft.com/v1/chat/completions \
-H "Authorization: Bearer sk-ony-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [
{"role": "user", "content": "Merhaba, nasılsın?"}
]
}'
Request with a System Prompt
cURL
curl https://api.onysoft.com/v1/chat/completions \
-H "Authorization: Bearer sk-ony-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [
{"role": "system", "content": "Sen yardımcı bir Türkçe asistansın."},
{"role": "user", "content": "Python nedir?"}
],
"temperature": 0.7,
"max_tokens": 500
}'
Request with Streaming
Add the stream: true parameter to receive a real-time response:
cURL
curl https://api.onysoft.com/v1/chat/completions \
-H "Authorization: Bearer sk-ony-your-api-key" \
-H "Content-Type: application/json" \
-N \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{"role": "user", "content": "Merhaba!"}],
"stream": true
}'
Note: Use the -N (--no-buffer) flag for streaming. This makes cURL display output directly without buffering.
Balance Lookup
cURL
curl https://api.onysoft.com/v1/balance \
-H "Authorization: Bearer sk-ony-your-api-key"
Listing Models
cURL
curl https://api.onysoft.com/v1/models \
-H "Authorization: Bearer sk-ony-your-api-key"
Using cURL on Windows
Mind the quotation marks when sending JSON in Windows Command Prompt or PowerShell:
Windows CMD
curl https://api.onysoft.com/v1/chat/completions ^
-H "Authorization: Bearer sk-ony-your-api-key" ^
-H "Content-Type: application/json" ^
-d "{\"model\": \"openai/gpt-4o-mini\", \"messages\": [{\"role\": \"user\", \"content\": \"Merhaba\"}]}"
Windows users: Use ^ as the line-continuation character. Escape the quotation marks inside the JSON with \".