codai docs
API referenceGateway

Tools

Verified web search and safe page fetching, the same tools the agent loop uses.

Both endpoints go through the rules gate and the per-key rate limit. search returns only snippets verified against the fetched page; fetch enforces SSRF checks on every redirect hop and a 3 MB cap. Details: tools guide.

POST
/v1/tools/search

Authorization

bearerAuth
AuthorizationBearer <token>

A codai API key (codai_ prefix). Ephemeral tokens from POST /v1/tokens are accepted only by /v1/realtime.

In: header

Header Parameters

x-request-id?string

Client correlation id; echoed back as x-codai-trace-id and persisted on the usage row.

Lengthlength <= 128

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Body of POST /v1/tools/search.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/v1/tools/search" \  -H "Content-Type: application/json" \  -d '{    "query": "curs BNR euro azi"  }'
{  "results": [    {      "title": "string",      "url": "http://example.com",      "snippet": "string",      "page_age": "string",      "source": "index",      "verified": true    }  ],  "provider": "codai",  "took_ms": 0,  "cached": true,  "coverage": 0,  "sources_tried": [    "string"  ],  "degraded": [    "string"  ],  "intent": "currency",  "rerank": {    "model": "string",    "ms": 0,    "n": 0  }}
POST
/v1/tools/fetch

Authorization

bearerAuth
AuthorizationBearer <token>

A codai API key (codai_ prefix). Ephemeral tokens from POST /v1/tokens are accepted only by /v1/realtime.

In: header

Header Parameters

x-request-id?string

Client correlation id; echoed back as x-codai-trace-id and persisted on the usage row.

Lengthlength <= 128

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Body of POST /v1/tools/fetch.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/v1/tools/fetch" \  -H "Content-Type: application/json" \  -d '{    "url": "https://www.bnr.ro/Cursul-de-schimb-524.aspx"  }'
{  "url": "string",  "final_url": "http://example.com",  "title": "string",  "byline": "string",  "description": "string",  "canonical": "http://example.com",  "lang": "string",  "content_type": "text/html",  "content": "string",  "chars": 0,  "truncated": true,  "took_ms": 0,  "cached": true}