cURL
Environment
List models
Chat
curl -s "$BASE/chat/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "llama3.1:8b",
"messages": [{"role": "user", "content": "One-word greeting."}]
}' | jq '.choices[0].message.content'
Chat — streaming (SSE)
curl -N "$BASE/chat/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "llama3.3:70b",
"stream": true,
"messages": [{"role": "user", "content": "Count to 10 slowly."}]
}'
The response is an text/event-stream with data: {...} lines. Parse by stripping data: and JSON-decoding each line until data: [DONE].
Embeddings
curl -s "$BASE/embeddings" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "embed/nomic-embed-text",
"input": ["hello world", "foo bar"]
}' | jq '.data[] | .embedding | length'