Terminal & curl
Discover models with GET /v1/models, call OpenAI-compatible endpoints with curl, stream responses, and use the Python SDK against api.undersky.ai.
Use standard HTTP tools against https://api.undersky.ai. Create API keys, top up credits, and manage your account in the Dashboard.
UnderSky CLI (account tools)
Install the undersky-cli / usai binaries for login, doctor checks, and control-plane helpers:
curl -fsSL https://raw.githubusercontent.com/leaperone/UnderSky/main/scripts/install-cli.sh | shUpdate with undersky-cli upgrade, or re-run the installer. Prebuilt archives ship on GitHub Releases tagged cli-v* (linux/macOS, x64 and arm64) with SHA256SUMS. If the GitHub repository is private, set GH_TOKEN (or GITHUB_TOKEN) with contents:read for install and upgrade.
Set your API key
Store your model API key in the shell for repeatable examples:
export UNDERSKY_API_KEY="sk-your-api-key"Never commit real API keys. Use Dashboard → Settings → API Keys to rotate compromised keys.
Discover models and endpoints
Public catalog endpoints do not require authentication:
curl -sS https://api.undersky.ai/v1/models | jq '.data[] | {id, owned_by}'
curl -sS https://api.undersky.ai/openapi.json | jq '.paths | keys[:10]'Browse the full reference on undersky.ai/docs.
Chat completion
curl -sS https://api.undersky.ai/v1/chat/completions \
-H "Authorization: Bearer $UNDERSKY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5-nano",
"messages": [{"role": "user", "content": "Hello!"}]
}' | jq '.choices[0].message.content'Streaming
curl -N https://api.undersky.ai/v1/chat/completions \
-H "Authorization: Bearer $UNDERSKY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5-nano",
"stream": true,
"messages": [{"role": "user", "content": "Count to three."}]
}'OpenAI SDK (Python)
pip install openaifrom openai import OpenAI
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.undersky.ai/v1",
)
response = client.chat.completions.create(
model="gpt-5-nano",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)Credits and usage
Account balance and usage history are available in Dashboard → Settings → Credit & Usage. Server integrations that already hold a scoped control token (lpc_…) can query balance with:
curl -sS https://api.undersky.ai/api/v1/credits/balance \
-H "Authorization: Bearer lpc-your-control-token" | jqScripting tips
Pipe JSON through jq, capture HTTP status with -w "%{http_code}", and retry on 429 with backoff. Parse response bodies only; treat stderr from your shell separately from API error payloads.