Reference

Base URL

https://coreloop.run/anthropic. The SDK appends /v1 itself. Every path below is relative to the base URL.

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://coreloop.run/anthropic",
  apiKey: process.env.CORELOOP_API_KEY,
});

Headers

HeaderNotes
x-api-keyRequired. A coreloop key. The key selects the organization.
anthropic-versionAccepted. Never required.
anthropic-betaAccepted. Never required.
request-idOn every response. Quote it when reporting a problem.

Errors

JSON
{
  "type": "error",
  "error": {
    "type": "not_found_error",
    "message": "session not found: sesn_..."
  },
  "request_id": "req_..."
}
TypeStatusCause
invalid_request_error400The request is malformed, or the resource is archived.
authentication_error401No key, or a key that is revoked or expired.
permission_error403The organization is waitlisted.
not_found_error404No such resource, or no such route.
api_error500Ours.

coreloop refuses a request over 32 MiB, and a skills upload over 30 MB, with request_too_large and 413, before the request gets an id.

A send takes at most 50 events, and a session create at most 50 initial_events. More is 400.

Pagination

Event types

What a session writes to its transcript. Webhooks carry their own types, listed on the webhooks page.

TypeFields
user.messagecontent
user.interruptnone
user.tool_confirmationtool_use_id, result, deny_message
agent.messagecontent
agent.thinkingnone
agent.tool_usename, input, evaluated_permission, evaluation
agent.tool_resulttool_use_id, content, is_error
agent.mcp_tool_usename, mcp_server_name, input, evaluated_permission, evaluation
agent.mcp_tool_resultmcp_tool_use_id, content, is_error
agent.custom_tool_usename, input
agent.thread_context_compactednone
user.custom_tool_resultcustom_tool_use_id, content, is_error
session.status_runningnone
session.status_idlestop_reason: end_turn, requires_action with event_ids, retries_exhausted, or budget_reached
session.errorerror, with a retry_status; an MCP error also names mcp_server_name
session.updatedthe fields that changed: agent, title, metadata, budget
session.usageusage, the session's totals, and budget while one is set; sent before each idle but a retries_exhausted one
span.model_request_startnone
span.model_request_endmodel_request_start_id, is_error, model_usage

Id prefixes

PrefixResource
agent_An agent
env_An environment
sesn_A session
sevt_A session event
skill_A skill
skver_A skill version
vlt_A vault
vcrd_A vault credential
req_A request
whe_A webhook event

Models and providers

Any model your keys serve. coreloop picks the first provider on the organization that can serve the id, and rewrites the id for that provider.

ModelServed by
claude-sonnet-5Anthropic, or OpenRouter when there is no Anthropic key.
gpt-5.6OpenAI, or OpenRouter when there is no OpenAI key.
openrouter/moonshotai/kimi-k3OpenRouter, always.
anthropic/claude-opus-5Anthropic, or OpenRouter.
openai/gpt-5.6OpenAI, or OpenRouter.
z-ai/glm-5.2OpenRouter.

Endpoints

Vaults

A vault holds credentials for MCP servers, one per server URL. A credential takes a static_bearer token or an mcp_oauth grant; environment_variable is 400. Every secret is encrypted at rest and no response returns it. Archiving a credential or its vault deletes its secrets.

An mcp_oauth grant with a refresh block is refreshed when a minute or less is left, and when its server refuses the token. A refresh the token endpoint refuses, with a 4xx or a 2xx that is not JSON, invalidates the credential and sends vault_credential.refresh_failed; an update with a new access or refresh token clears it. An expired token is still presented, and the server decides; one the server refuses with no way to refresh it is invalidated. mcp_oauth_validate probes the server and answers valid, invalid or unknown.

Five differences from the Managed Agents API. A refresh never follows a redirect, and keeps the grant, where the Managed Agents API follows it. Under client_secret_basic it sends client_id only in the Basic header. The bodies mcp_oauth_validate echoes are scrubbed of every secret the credential holds, and are cut at 4096 characters without redacting long runs. A token whose lifetime is within the minute is refreshed once per connection, where the Managed Agents API refreshes it before every request.

A turn presents a credential to the MCP server whose URL it holds, from the vaults its session names in vault_ids.

An end user's own models

Not in the Managed Agents API. A vault can also hold an end user's own model credentials, so their sessions run on their keys or their ChatGPT subscription instead of the organization's. auth.type model_api_key takes a provider (openai, anthropic or openrouter) and an api_key. The key is read against its provider before it is stored: one the provider calls invalid answers 400 invalid_request_error with the provider's words, and an outage or a slow provider stores it unchecked. openai_subscription takes nothing else: the create answers auth.connection with a user_code and a verification_uri to show the end user, and its status is pending. A retrieve while pending asks OpenAI, at most once every 5 seconds, and answers connected once the end user approved, or failed with a message. An update with the same auth starts a new code on the same credential; its old tokens serve until the new ones land. A new code the end user refuses leaves it connected on the old tokens, with the refusal as its message.

A vault holds one model credential per provider, and openai_subscription is a provider of its own. A second answers 409 until the first is archived.

A session's coreloop.payer, set at create and fixed after, says who pays: organization, the default, or end_user. An organization's session runs on the organization's keys and ignores the model credentials in its vaults. An end user's session runs only on the model credentials in its vaults, never on the organization's keys. Each call takes the model's first provider with a credential that serves it, across the session's vaults in vault_ids order. A GPT model tries the subscription, then openai, then openrouter; a Claude model tries anthropic, then openrouter. A subscription that is broken, spent until its reset, or does not list the model is skipped. With none left, the turn stops with an error naming why, and the session waits for the client's next message.

Not built yet

These are part of the Managed Agents API and coreloop does not run them. coreloop stores any configuration for them that a request carries and echoes it back.