Skip to main content

Using the gateway

Set your client's base URL to http://localhost:4000/v1 and its API key to your LiteLLM bearer key. The examples use LITELLM_MASTER_KEY from your shell. Use the value from .env, or the AIGATE_TOKEN value if you did not set a separate LiteLLM key.

curl --fail-with-body http://localhost:4000/v1/models \
-H "Authorization: Bearer $LITELLM_MASTER_KEY"

Generate an image​

Enable Imagies first. This example uses the CPU profile. With the CUDA profile, use local-imagies-cuda-sd-turbo.

curl --fail-with-body http://localhost:4000/v1/images/generations \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-H "Content-Type: application/json" \
--data '{
"model": "local-imagies-cpu-sd-turbo",
"prompt": "A red panda in a forest",
"size": "512x512",
"response_format": "b64_json"
}'

The service index links to recipes for speech and transcription, audio editing, video processing, and the other direct service endpoints. See MCP tools for the agent-facing interface.

Queue a request​

Use /q/ to queue long-running requests. The gateway returns a job ID immediately and processes the request in the background.

# Submit and get a job ID
curl http://localhost:4000/q/v1/chat/completions \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "cerebras-gpt-oss-120b", "messages": [{"role": "user", "content": "write a novel"}]}'
# → 202 {"jobId": "550e8400-e29b-41d4-a716-446655440000"}

# check status
curl http://localhost:4000/q/__jobs/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer $LITELLM_MASTER_KEY"
# → {"id": "...", "status": "running"}

# get the response (replays upstream response exactly)
curl http://localhost:4000/q/__jobs/550e8400-e29b-41d4-a716-446655440000/content \
-H "Authorization: Bearer $LITELLM_MASTER_KEY"
# → {"choices": [...], "usage": {...}}

# cancel
curl -X DELETE http://localhost:4000/q/__jobs/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer $LITELLM_MASTER_KEY"

Only OpenAI API paths (/v1/chat/completions, /v1/embeddings, /v1/audio/*, /v1/images/*, /v1/responses) are queued. Health checks, model lists, key management, and admin UI requests pass through to LiteLLM directly.

Configurable via .env:

VariableDefaultWhat it does
PROXQ_CONCURRENCY10How many workers process jobs simultaneously
PROXQ_TASK_RETENTION1hHow long completed jobs stay in Redis
PROXQ_UPSTREAM_TIMEOUT10mMax time to wait for LiteLLM to respond
PROXQ_MAX_RETRIES0Retry failed upstream calls (0 = no retries)
PROXQ_RETRY_DELAY30sDelay between retries (0 = exponential backoff)
PROXQ_MAX_BODY_SIZE10MBMax request body size for queued requests
PROXQ_DIRECT_PROXY_THRESHOLD10MBBodies larger than this bypass the queue
PROXQ_CACHE_MODEnonenone, memory (LRU), or redis, cache upstream responses
PROXQ_CACHE_TTL5mHow long cached responses stay fresh
PROXQ_CACHE_MAX_ENTRIES10000Max entries for in-memory LRU cache