Y2 Elite workspaces are rolling out for teams
Y2Y2Docs

Agent Y2 API

Stream Y2's preconfigured workspace-aware agent through native or OpenAI-compatible requests

Agent Y2 exposes the same preconfigured intelligence agent used by the Y2 copilot through two API-key-authenticated streaming endpoints. It uses the key's workspace, plan entitlements, chat credit budget, persisted thread history, and allowed Y2 tools.

Agent Y2 is not a model gateway

API callers cannot select an arbitrary model, replace the fixed system instructions, enable onboarding mode, or attach files in v1. The model value on the OpenAI-compatible route is a Y2 routing alias, not model selection.

Choose an endpoint

Both endpoints use https://api.y2.dev/api/v1.

EndpointStream formatChoose it when
POST /agent-y2/chat/streamVercel AI SDK UI message streamYour client understands the native AI SDK protocol
POST /chat/completionsOpenAI-style chat.completion.chunk server-sent eventsYour client already consumes streaming chat completions

The routes share the same Agent Y2-specific rate-limit pool. Switching formats does not create a second quota.

Create a scoped key

Open API Keys

In the workspace that should own the threads and tool actions, open Settings → Developers → API Keys.

Grant agent:y2

Create a dedicated key with the agent:y2 scope. New API-key creation requires Pro or Elite. Existing Lite keys remain usable only with the scopes already granted to them.

Store the key on a trusted server

Send it as Authorization: Bearer $Y2_API_KEY. Do not put an Agent Y2 key in browser bundles, prompts, metadata, logs, or public repositories.

Agent Y2 does not support x402. A 402 response from these routes describes plan, chat-credit, or upstream-provider credit exhaustion; it is not a payment challenge.

Send a native request

Terminal
curl -N -i "https://api.y2.dev/api/v1/agent-y2/chat/stream" \
  -H "Authorization: Bearer $Y2_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {
        "role": "user",
        "parts": [
          { "type": "text", "text": "What changed in cyber risk this week?" }
        ]
      }
    ],
    "metadata": {
      "source": "customer_crm",
      "externalThreadId": "case-123"
    }
  }'

The response is an AI SDK UI message stream. API responses omit internal reasoning parts even though the in-app stream can include them.

Read the X-Thread-Id response header and store it. Continue the conversation by sending that ID in the next native request body:

request.json
{
  "threadId": "j57...",
  "messages": [
    {
      "role": "user",
      "parts": [{ "type": "text", "text": "Which entities should I watch next?" }]
    }
  ]
}

Send an OpenAI-compatible request

Terminal
curl -N -i "https://api.y2.dev/api/v1/chat/completions" \
  -H "Authorization: Bearer $Y2_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "y2-agent",
    "stream": true,
    "messages": [
      {
        "role": "user",
        "content": "Summarize the latest Y2 platform capabilities."
      }
    ]
  }'

The compatibility route requires stream: true. model is optional; when supplied, it must be y2-agent or agent-y2. It emits a role chunk, text-delta chunks, a final chunk with finish_reason: "stop", and data: [DONE].

To continue a conversation, pass threadId in the JSON body or send the prior ID in an X-Thread-Id request header.

Compatibility fields do not change Agent Y2

System, developer, and tool messages are accepted so OpenAI-oriented clients can serialize their transcript, but they are excluded from Agent Y2's model context. Extra OpenAI fields such as temperature, max_tokens, and tool definitions are not part of the v1 contract and do not configure the agent.

Understand thread context

Request stateContext used by Agent Y2
No threadIdCreates an API-source thread and uses non-empty user and assistant text from the supplied transcript
Existing threadIdVerifies the same user, API source, and workspace, then loads up to 40 persisted messages from that thread
Latest user messageSaved to the thread and used as the new prompt
System, developer, or tool transcript entriesAccepted where compatible but not used to override or extend the fixed prompt

A thread created in the app cannot be continued through the API. A workspace-scoped API key also cannot continue a thread from another workspace.

The server returns 400 for an invalid ID shape, 404 for a missing thread, and 403 when the thread exists outside the caller's allowed source, user, or workspace scope.

Available tools

The exact tool set is assembled for every request from current workspace entitlements.

Tool categoryAvailability
Y2 documentation searchAlways registered
Public briefing search and followRegistered for standard Agent Y2 sessions
News searchRegistered for standard sessions
Web searchRequires the workspace web-search entitlement
Profile creation and editingRequires remaining custom-profile capability and metering context
OSINT searchRequires OSINT entitlement
Y2 Global Knowledge retrievalRequires Chat entitlement; searches only authorized shared and key-workspace corpora
Cyber, FININT, markets, entity, incident, and investigation toolsAdded according to the related intelligence entitlements
Image generationRequires image-generation entitlement and a compatible selected agent path

Tool availability does not guarantee that the agent will call a tool. Tool actions still enforce the underlying workspace permissions and resource limits.

Agent Y2 uses its existing agent:y2 scope when it invokes Y2 Global Knowledge. Do not add intel:knowledge to an Agent Y2 key unless the same integration also calls the direct retrieval endpoint. Direct retrieval and agent execution are separate least-privilege surfaces.

Metadata behavior

Both routes accept a strict metadata object:

{
  "metadata": {
    "source": "ops_console",
    "externalUserId": "analyst-42",
    "externalThreadId": "case-123"
  }
}
FieldMaximumCurrent behavior
source128 charactersAccepted for compatibility; the thread source is still recorded as api
externalUserId256 charactersAccepted but not currently persisted to the thread
externalThreadId256 charactersStored when Y2 creates a new thread; it does not replace the Y2 threadId

Unknown metadata properties fail strict validation. Keep your own correlation log and never put secrets or full customer records in metadata.

Provider privacy controls

The current Agent Y2 executor selects chat models marked as Zero Data Retention capable and sends OpenRouter provider options with zdr: true and data_collection: "deny".

These controls govern the external model request. Y2 still stores API-source threads, messages, request attribution, tool results, and usage records under Y2's product data lifecycle. See the Privacy Policy for the customer-facing data terms.

Rate limits and response headers

Agent Y2 applies these limits in addition to the API key's normal plan limits:

Limit scopePer minutePer day
API key5100
User or workspace aggregate10250

Inspect Retry-After, the normal X-RateLimit-* headers, and the X-Y2-Agent-RateLimit-* headers. Successful streams also return X-Thread-Id, X-Y2-Agent: y2, and X-Y2-Agent-Mode: copilot.

Error guide

StatusCommon causeResponse
400Invalid JSON, missing latest user text, unsupported alias, invalid thread ID, or native modelId, isOnboarding, or attachmentsCorrect the request; do not retry unchanged
401Missing, malformed, revoked, or invalid API keyReplace or rotate the credential
402Subscription, monthly chat-credit, or upstream provider credit exhaustionCheck plan and chat usage; do not start x402 handling
403Missing scope, no chat entitlement, blocked access, or unauthorized threadCheck key scope, workspace, plan, and thread origin
404Supplied thread no longer existsStart a new thread or correct the stored ID
429Normal API or shared Agent Y2 limit exceededBack off for Retry-After seconds
500Stream preparation or provider execution failedRetry with backoff and retain X-Request-Id for support