DocsAPI Keys

API Keys

OpenAI-compatible API for your AI employees.

Overview

Every deployed agent gets an OpenAI-compatible API endpoint. This means you can use any SDK or HTTP client that supports the OpenAI chat completions format to interact with your AI employees programmatically. No custom integration required.

Creating an API Key

API key creation dialog with name field and Create button
Create an API key from the agent's post-deploy page or from the Agents list.

You can create an API key from the agent's post-deploy page or from the Agents list by clicking the API key button on any deployed agent card. Give it a name, click Create, and your key is ready.

Warning
The API key is shown only once. Copy it immediately — you won't be able to see it again. If lost, create a new key.

Keys are hashed and stored securely. Oya cannot recover a lost key.

Endpoint

Endpoint
https://oya.ai/api/v1/chat/completions

Compatible with OpenAI's chat completions API format.

Usage Examples

cURL

cURL example for calling the API
Use cURL to test your API key from the terminal.
bash
curl -X POST https://oya.ai/api/v1/chat/completions \ -H "Authorization: Bearer a2a_your_key_here" \ -H "Content-Type: application/json" \ -d '{"model":"gemini/gemini-2.0-flash","messages":[{"role":"user","content":"Hello"}]}' # Continue a conversation using thread_id from the first response: curl -X POST https://oya.ai/api/v1/chat/completions \ -H "Authorization: Bearer a2a_your_key_here" \ -H "Content-Type: application/json" \ -d '{"model":"gemini/gemini-2.0-flash","messages":[{"role":"user","content":"Follow up question"}],"thread_id":"thread_id_from_previous_response"}'

Python

Python example using the OpenAI SDK
Use the official OpenAI Python SDK with your Oya base URL.
python
# pip install openai from openai import OpenAI client = OpenAI( api_key="a2a_your_key_here", base_url="https://oya.ai/api/v1", ) # First message — starts a new thread response = client.chat.completions.create( model="gemini/gemini-2.0-flash", messages=[{"role": "user", "content": "Hello"}], ) print(response.choices[0].message.content) # Continue the conversation using thread_id thread_id = response.thread_id response = client.chat.completions.create( model="gemini/gemini-2.0-flash", messages=[{"role": "user", "content": "Follow up question"}], extra_body={"thread_id": thread_id}, ) print(response.choices[0].message.content)

TypeScript

typescript
// npm install openai // Run with: npx tsx script.ts import OpenAI from "openai"; const client = new OpenAI({ apiKey: "a2a_your_key_here", baseURL: "https://oya.ai/api/v1", }); async function main() { // First message — starts a new thread const response = await client.chat.completions.create({ model: "gemini/gemini-2.0-flash", messages: [{ role: "user", content: "Hello" }], }); console.log(response.choices[0].message.content); // Continue the conversation using thread_id const threadId = (response as any).thread_id; const followUp = await client.chat.completions.create({ model: "gemini/gemini-2.0-flash", messages: [{ role: "user", content: "Follow up question" }], // @ts-ignore — custom field thread_id: threadId, }); console.log(followUp.choices[0].message.content); } main();
Tip
Supported models: gemini/gemini-2.0-flash, gemini/gemini-2.5-flash, gemini/gemini-2.5-pro, gemini/gemini-3-flash-preview, gemini/gemini-3-pro-preview, anthropic/claude-sonnet-4-6, anthropic/claude-haiku-4-5-20251001.
Tip
Pass thread_id in the request body to continue a conversation. The first response includes a thread_id field — use it in subsequent requests to keep context.
Tip
All API keys start with the a2a_ prefix for easy identification in your code.

Authentication

Pass your API key via either header format:

  • Authorization: Bearer a2a_your_key_here
  • X-API-Key: a2a_your_key_here

Keys are per-agent — each key is scoped to the single agent it was created for. You need separate keys for different agents.

Warning
API calls consume your billing balance just like chat messages. Monitor usage in the Billing page.

Browser-Stored Key

The API Keys page includes a "Your API key (for this browser)" section that saves a key to your browser's localStorage. This is a convenience feature — it pre-fills code examples with your key and persists across page loads. Clear it anytime.

Key Management

  • Last used tracking — Each key shows when it was last used for audit purposes.
  • Multiple keys — Create separate keys for different environments (production, staging, mobile).
  • Key rotation — Create a new key, update your integration, then delete the old one.
  • Instant revocation — Deleted keys stop working immediately.

Rate Limits & Errors

  • 429 Too Many Requests — rate limited
  • 402 Payment Required — insufficient balance
  • 401 Unauthorized — invalid or expired key
Warning
If you get 402 errors, top up your balance at /billing. The agent will resume immediately after payment.