Start
Make your first request.
Connect to CostIQ from a terminal in a few minutes. You need a CostIQ-issued API key and cURL.
Before you begin
Ask your CostIQ administrator for a key created specifically for you or the service you are connecting. Do not share a credential across people or environments.
01
Configure your shell
The silent prompt keeps the key out of your terminal history and screen.
Shell
export COSTIQ_BASE_URL=https://inference.costiq.xyz/v1
export COSTIQ_MODEL=general-fast
printf 'CostIQ API key: ' >&2
read -r -s COSTIQ_API_KEY && printf '\n' >&2
export COSTIQ_API_KEY02
List available models
A healthy, authorized request returns general-fast in the response data.
GET /models
curl "$COSTIQ_BASE_URL/models" \
-H "Authorization: Bearer $COSTIQ_API_KEY"03
Create a completion
Send messages using the familiar OpenAI Chat Completions shape.
POST /chat/completions
curl "$COSTIQ_BASE_URL/chat/completions" \
-H "Authorization: Bearer $COSTIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "general-fast",
"messages": [
{"role": "user", "content": "Explain this in one sentence."}
],
"stream": false
}'04
Stream a response
Set stream to true and consume server-sent events until the terminal [DONE] event.
Streaming cURL
curl -N "$COSTIQ_BASE_URL/chat/completions" \
-H "Authorization: Bearer $COSTIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "general-fast",
"messages": [{"role": "user", "content": "Write a haiku."}],
"stream": true
}'