Overview
The LLM proxy endpoints allow clients to make LLM completion requests through the Loom server without exposing API keys. The server handles:- API key management and rotation
- Request/response logging and auditing
- Rate limiting and retry logic
- Token usage tracking
- Server-to-client queries during streaming
- Anthropic (Claude models)
- OpenAI (GPT models)
- Vertex AI (Google Cloud)
- Z.ai (Z.ai models)
Request Format
All proxy endpoints accept a standardLlmRequest payload:
Model identifier (e.g.,
"claude-sonnet-4", "gpt-4o")Array of message objects with
role and contentTool definitions for function calling
System prompt
Maximum tokens to generate
Sampling temperature (0.0-1.0)
Anthropic Complete
Request Body
See Request Format above.Response
Assistant message with
role: "assistant" and contentArray of tool call objects (if any)
Token usage:
{input_tokens: number, output_tokens: number}Reason for completion:
"stop", "length", "tool_use", etc.Example
Anthropic Stream
Request Body
See Request Format above.Response
Returnstext/event-stream with events tagged as event: llm.
Event Types
Text Delta
Tool Call Delta
Server Query
Server requests information from the client:POST /api/sessions/{session_id}/query-response.
Completed
Error
Example
OpenAI Complete
Request/Response
Same format as Anthropic endpoints. See Request Format and Anthropic Complete.Example
OpenAI Stream
Example
Vertex Complete
Request/Response
Same format as Anthropic endpoints. See Request Format and Anthropic Complete.Example
Vertex Stream
Example
Z.ai Complete
Request/Response
Same format as Anthropic endpoints. See Request Format and Anthropic Complete.Example
Z.ai Stream
Example
Error Handling
All endpoints return errors in this format:Common Errors
Rate Limiting
When rate limited, the response includes retry information:Audit Logging
All LLM requests are logged for audit purposes:- LlmRequestStarted: Provider, model, message count
- LlmRequestCompleted: Provider, model, tool call count
- LlmRequestFailed: Provider, model, error message