Skip to main content

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
Supported Providers:
  • Anthropic (Claude models)
  • OpenAI (GPT models)
  • Vertex AI (Google Cloud)
  • Z.ai (Z.ai models)

Request Format

All proxy endpoints accept a standard LlmRequest payload:
model
string
required
Model identifier (e.g., "claude-sonnet-4", "gpt-4o")
messages
array
required
Array of message objects with role and content
tools
array
default:"[]"
Tool definitions for function calling
system
string
System prompt
max_tokens
integer
Maximum tokens to generate
temperature
number
Sampling temperature (0.0-1.0)

Anthropic Complete

Synchronous Anthropic completion. Returns the full response when complete.

Request Body

See Request Format above.

Response

message
object
Assistant message with role: "assistant" and content
tool_calls
array
Array of tool call objects (if any)
usage
object
Token usage: {input_tokens: number, output_tokens: number}
finish_reason
string
Reason for completion: "stop", "length", "tool_use", etc.

Example

Response (200 OK):

Anthropic Stream

Streaming Anthropic completion via Server-Sent Events (SSE).

Request Body

See Request Format above.

Response

Returns text/event-stream with events tagged as event: llm.

Event Types

Text Delta

Tool Call Delta

Server Query

Server requests information from the client:
Client must respond via POST /api/sessions/{session_id}/query-response.

Completed

Error

Example

Stream output:

OpenAI Complete

Synchronous OpenAI completion.

Request/Response

Same format as Anthropic endpoints. See Request Format and Anthropic Complete.

Example

OpenAI Stream

Streaming OpenAI completion via SSE. Same event format as Anthropic Stream.

Example

Vertex Complete

Synchronous Vertex AI completion (Google Cloud).

Request/Response

Same format as Anthropic endpoints. See Request Format and Anthropic Complete.

Example

Vertex Stream

Streaming Vertex AI completion via SSE. Same event format as Anthropic Stream.

Example

Z.ai Complete

Synchronous Z.ai completion.

Request/Response

Same format as Anthropic endpoints. See Request Format and Anthropic Complete.

Example

Z.ai Stream

Streaming Z.ai completion via SSE. Same event format as Anthropic Stream.

Example

Error Handling

All endpoints return errors in this format:

Common Errors

Rate Limiting

When rate limited, the response includes retry information:
Clients should respect the retry delay and implement exponential backoff.

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
Logs are queryable via the admin audit log endpoints.