Clovie Docs

Reference

Connect an agent

Send your agent's model requests through the Clovie gateway with any OpenAI- or Anthropic-compatible SDK, or with the Clovie SDK.

To connect an agent you change two things: the base URL it sends requests to, and the key it sends. Everything else, including your prompts, tools and streaming, stays the same.

What you need

  • Your gateway URL. For Clovie SaaS it is https://gateway.clovie.io. For a self-hosted install, ask your administrator.
  • An agent key for the agent, from AI Governance → Agents → Registry. See Agents.
  • A model your organization has enabled in AI Governance → Models → Catalog.

Authentication

Send the agent key as a bearer token:

Authorization: Bearer YOUR_CLOVIE_AGENT_KEY

For the Messages format, the gateway also accepts the key in the x-api-key header, which is what Anthropic SDKs send.

Chat Completions

Works with OpenAI SDKs and most agent frameworks.

Python (OpenAI SDK)
from openai import OpenAI

client = OpenAI(base_url="https://gateway.clovie.io/v1", api_key="YOUR_CLOVIE_AGENT_KEY")

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Summarize our refund policy."}],
)
TypeScript (OpenAI SDK)
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://gateway.clovie.io/v1", apiKey: process.env.CLOVIE_API_KEY });

const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Summarize our refund policy." }],
});

Messages

Works with Anthropic SDKs and tools built on them.

Python (Anthropic SDK)
import anthropic

client = anthropic.Anthropic(base_url="https://gateway.clovie.io", api_key="YOUR_CLOVIE_AGENT_KEY")

message = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Summarize our refund policy."}],
)

Tools that read ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY from the environment can be pointed at the gateway without code changes.

Responses

The gateway also accepts the OpenAI Responses format at /v1/responses, with the same base URL and key as Chat Completions.

Streaming

Streaming works in every format. Ask for it the way your SDK normally does, for example stream=True. If a policy or budget stops a request while it is streaming, the stream ends with an error event that says why.

Group calls into one run

An agent task often makes several model calls. To see them together as one run in AI Governance → Activity → Agent runs, send the same x-clovie-run-id header value on each call of the task.

The Clovie SDK for Python

The Clovie SDK wraps the gateway and handles approvals for you: when a policy holds a request for approval, the SDK waits for the decision and then retries.

pip install clovie-sdk
from clovie import ClovieClient

client = ClovieClient()  # reads CLOVIE_API_KEY and CLOVIE_GATEWAY_URL

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Summarize our refund policy."}],
)

Set CLOVIE_API_KEY to the agent's key. CLOVIE_GATEWAY_URL defaults to https://gateway.clovie.io; set it if you use a self-hosted install.

When a request is stopped

If the gateway stops a request, the agent receives a standard error response with a status code, a machine-readable code and a message that explains why. The most common ones:

StatusCodeMeaning
401invalid_api_keyThe agent key is missing, wrong or revoked.
403policy_deniedAn enforced policy blocked the request. The message names the policy.
403model_not_enabledThe model is not enabled for your organization.
429budget_exceededAn enforced budget is exhausted.
429rate_limit_exceededA rate limit was reached. Retry after the time in the Retry-After header.
503agent_disabledThe agent's kill switch is on.

Signed-in users can find the full list, with what to do for each, in the error code reference inside the product.

On this page