Skip to main content
This page is for anyone building a system that calls Prem API without a human watching each call: agent loops, batch jobs, evaluation harnesses, or any tool that fires many requests unattended. Unattended callers hit different failure modes than an interactive app. A truncated response, a burned rate-limit budget, or a duplicated retry may not be noticed until it has already happened many times.
If you want an AI coding agent (Claude Code, Cursor, Windsurf) to help you write this integration, see Use LLMs. It loads the Prem API docs into your coding agent’s context. This page is about the system you build calling Prem API, not the coding agent that helps you build it.

Pick your integration

The TypeScript SDK and Confidential Proxy are the confidential paths. ZDR does not provide enclave confidentiality. Use ZDR only when its model catalog is more important than confidential processing.
See Developer Experience for both, in detail. For an agent that runs continuously, run the Confidential Proxy as a background daemon rather than in the foreground:
See Confidential Proxy for the full daemon lifecycle (start / stop / status, state and log files, graceful shutdown).

Required configuration

Both confidential integration paths need the same four values. Set them once in the environment where the agent runs, not for each call: Get the current PROXY_URL / ENCLAVE_URL values from dashboard.prem.io/endpoints.json at deploy time rather than hardcoding them. ZDR uses the same PREM_API_KEY at https://gateway.prem.io/openai. See ZDR overview for the ZDR setup.

Gotchas that only show up at automation scale

These are easy to miss in a one-off script and expensive to miss in a loop that runs thousands of times.
Reasoning models generate a chain-of-thought before every answer unless you turn it off. Those tokens are billed, count against your rate limit, and share the same inference’s token budget as the visible answer. Reasoning can consume a tight max_completion_tokens value and leave message.content: null.Default to the lowest reasoning_effort value that the model family accepts in automated pipelines unless you explicitly consume the reasoning trace. See Models & Pricing for the values that each family accepts.
Your tier sets separate concurrency limits for Confidential and ZDR. All keys and users in an organization share each family’s concurrency limit. Every endpoint in a family counts toward the same limit. A request above the limit returns 429 with:
The TypeScript SDK uses the encrypted /rvenc/chat/completions endpoint. The endpoint returns JSON by default. It returns text/event-stream when stream: true. A request holds a concurrency slot while it waits for model capacity and while inference runs. Use a shared queue or concurrency limit for workers in the organization and inference family. More API keys do not increase the limit.All keys in the organization share each family’s request-rate, token, and audio allowances. Confidential usage does not use the ZDR allowance. ZDR usage does not use the Confidential allowance. See Tiers for the current limits and allowance scope.
Some 429 responses have a structured body and a Retry-After header. An upstream rate limit can return a generic body without a Retry-After header. Read the HTTP status and the error details. Use exponential backoff for temporary limits when the header is absent. Set a maximum number of retries. Stop automatic retries for this error: Inference request allowance exhausted. Contact us for higher limits. Time does not restore this allowance. See Rate limits.
An agent that retries blindly after a timeout or a 5xx can duplicate the underlying action (a file upload, a resource creation). Send an Idempotency-Key header so a retried request has the same effect as the original. See Idempotency.
A null or empty message.content is not necessarily a failed call. If finish_reason is "length", reasoning, a long answer, or both consumed the token budget. Treat it as truncation and retry with a larger max_completion_tokens or a lower reasoning_effort, not as an empty result to discard.

A request shaped for unattended use

Before you deploy

  • reasoning_effort set deliberately (the lowest value the model family accepts, or a value you’ve budgeted max_completion_tokens for)
  • Retries use exponential backoff and don’t assume Retry-After is present
  • Idempotency keys on any retried write
  • Concurrent requests stay within each family’s concurrency limit
  • Every response checks finish_reason before treating content as final
  • support_id is logged on every error for support escalation
This checklist is agent-specific. For the full production checklist (key management, tiers, attestation), see Production Checklist.

Tiers

The request, token, and audio limits of each tier.

Rate limits

Retry code, the 429 shapes, and non-standard 429 bodies.

Idempotency

Make retries safe with the Idempotency-Key header.

Confidential Proxy

Daemon mode, config, and connecting any language.

OpenCode

Connect OpenCode to Prem API through the local proxy.

OpenClaw

Configure a Prem-backed OpenClaw provider and its tool boundary.

Hermes Agent

Use an explicit Chat Completions transport through Prem.

Goose

Connect Goose’s built-in OpenAI provider to Prem.

Cursor compatibility

Review why Cursor’s provider override is not a confidential local path.

Codex CLI compatibility

Review the current Responses API protocol mismatch.