APIIntegrations
curl
Talk to OwnLLM from a shell script with curl. Streaming and tool calling included.
The OwnLLM API is plain HTTPS + JSON. Anything that speaks HTTPS can
call it; curl is the simplest way to verify the integration.
List models
export OPENAI_BASE_URL=https://acme-prod.ownllm.app/v1
export OPENAI_API_KEY=sk-ownllm-...
curl -s "$OPENAI_BASE_URL/models" \
-H "Authorization: Bearer $OPENAI_API_KEY" | jq .Single chat completion
curl -s "$OPENAI_BASE_URL/chat/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "llama-3.3-70b",
"messages": [{"role": "user", "content": "What is OwnLLM?"}]
}' | jq -r '.choices[0].message.content'Streaming chat
Use --no-buffer so curl doesn't hold tokens in its buffer:
curl -N -s "$OPENAI_BASE_URL/chat/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "llama-3.3-70b",
"messages": [{"role": "user", "content": "Why is the sky blue?"}],
"stream": true
}'To extract just the content deltas:
curl -N -s "$OPENAI_BASE_URL/chat/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "model": "llama-3.3-70b", "messages": [{"role":"user","content":"Hi"}], "stream": true }' \
| grep -E '^data: ' \
| grep -v '\[DONE\]' \
| sed 's/^data: //' \
| jq -j '.choices[0].delta.content // empty'Tool calling
curl -s "$OPENAI_BASE_URL/chat/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d @- <<'JSON'
{
"model": "qwen2.5:32b",
"messages": [{"role": "user", "content": "What's the weather in Paris?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather.",
"parameters": {
"type": "object",
"properties": { "location": { "type": "string" } },
"required": ["location"]
}
}
}],
"tool_choice": "auto"
}
JSONHealth check from CI
A minimal liveness check for a deploy pipeline:
http_status=$(curl -s -o /dev/null -w '%{http_code}' \
"$OPENAI_BASE_URL/models" \
-H "Authorization: Bearer $OPENAI_API_KEY")
[ "$http_status" = "200" ] || exit 1A 200 means both the site and the paired GPU machine are healthy
— /v1/models queries the agent through the tunnel.