# Deep Agents OKF Consumer
A terminal assistant that answers questions from the Open Knowledge Format
(OKF) documentation in `bundle/`. It reads the local bundle first and can fetch
linked Cloudflare or Vercel documentation pages when a digest needs more detail.
## Setup
Requires Python 3.12 or newer and [uv](https://docs.astral.sh/uv/).
```sh
uv sync
cp .env.example .env
```
Set `OPENROUTER_API_KEY` in `.env`. `MODEL_ID` is optional and defaults to
`google/gemini-3.8-flash`.
The `bundle/` directory must be at the project root. The agent has read-only
access to that directory.
## Ask a question
Run a single query:
```sh
uv run deepagents-okf-consumer "How do Vercel and Cloudflare queues differ?"
```
Start an interactive session by omitting the question:
```sh
uv run deepagents-okf-consumer
```
Enter `/quit` to end the session. The CLI shows bundle and fetch activity as it
happens, then renders the answer as terminal Markdown. Interactive turns share
conversation context while the process is running. The current in-memory
checkpointer forgets that context when the CLI exits.
## Research behavior
- The agent starts from bundle indexes, then searches and reads relevant
concept documents.
- If a digest lacks needed detail, `fetch_url` tries the page's `.md` URL and
falls back to readable text extracted from HTML.
- URL fetching is limited to HTTPS pages on `cloudflare.com` and `vercel.com`.
- Answers should cite bundle file paths and relevant upstream URLs. The bundle
is curated and incomplete, so the agent may report gaps or fetch upstream
sources.
Example questions:
- How do Cloudflare Queues and Vercel Queues differ in consumer models,
retries, and delivery guarantees?
- Compare Cloudflare Workers with Vercel Functions for a latency-sensitive API.
- What should I consider when choosing between Cloudflare R2 and Vercel Blob?
- How would I expose a private service with Cloudflare Tunnel, and what
deployment details should I verify upstream?
- What are the main caching layers on Vercel, and how do they interact?
- Which platform has a built-in queue consumer model that fits a background
image-processing workload?
- What does the bundle say about Vercel pricing, and which current rates should
I verify on the upstream pages?
- Does the bundle cover Cloudflare WAF configuration? If not, find the relevant
upstream documentation.
- What are the trade-offs between Cloudflare Durable Objects and Vercel Queues
for coordinating asynchronous work?
## Example
```text
uv run deepagents-okf-consumer "What can you tell me about vercel ai gateway?"
→ Finding bundle documents
✓ Finding bundle documents complete
→ Reading bundle document: /vercel/ai/ai-gateway.md
✓ Reading a bundle document complete
→ Searching bundle content
✓ Searching bundle content complete
→ Reading bundle document: /vercel/ai/agent-plugin.md
✓ Reading a bundle document complete
→ Searching bundle content
✓ Searching bundle content complete
→ Searching bundle content
✓ Searching bundle content complete
→ Searching bundle content
✓ Searching bundle content complete
→ Searching bundle content
✓ Searching bundle content complete
→ Searching bundle content
✓ Searching bundle content complete
→ Fetching upstream documentation
✓ Fetching upstream documentation complete
Vercel AI Gateway is a managed unified API and routing control plane designed to call AI models across multiple inference providers from any infrastructure, without
having to build and maintain custom proxy, logging, or failover infrastructure.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key Capabilities & Features
1 Centralized Credentials & BYOK (Bring Your Own Key)
• Authenticate applications once through AI Gateway using either AI Gateway system credentials or your own provider accounts via BYOK.
• If a BYOK request fails, AI Gateway can be configured to fall back to system credentials.
• AI Gateway adds zero markup to provider token prices, even when using BYOK.
2 Universal & Infrastructure-Agnostic Access
• Applications do not need to be deployed on Vercel. AI Gateway can be called from any server, local environment, or cloud provider using an AI Gateway API key
(AI_GATEWAY_API_KEY).
• Applications running on Vercel deployments can authenticate using OpenID Connect (OIDC) without managing static secrets.
• Vercel CLI provides the ai-gateway command to manage resources and API keys.
3 Protocol & SDK Compatibility AI Gateway can be used as a drop-in replacement across various clients and SDKs:
• Vercel AI SDK (e.g., using generateText with models like openai/gpt-4o or similar provider strings).
• OpenAI Compatible APIs: Works with standard OpenAI Chat Completions (endpoint: https://ai-gateway.vercel.sh/v1/chat/completions) and the OpenAI Responses API.
• Anthropic Messages API.
• Supported Coding Agents & Tools: Claude Code, Cursor, Codex, etc., via Vercel CLI or framework integrations.
• HTTP / cURL / Python / TypeScript.
4 Multi-Provider Routing and Automated Failover
• Dynamically route requests across healthy providers.
• Define custom provider ordering, filtering, and fallback models if the primary provider or model experiences downtime or rate limiting.
• Routing rules and virtual model configs can also be inspected and managed via the Vercel REST API (e.g., GET/POST /v1/ai-gateway/virtual-model-configs, GET/POST
/v1/ai-gateway/rules).
5 Supported Modalities & Tooling
• Broad modality coverage: text generation, image generation, video generation, speech, transcription, realtime, embeddings, and reranking.
• Full support for file inputs and tool calling where supported by underlying models.
6 Observability & Request Logging
• Detailed request logs track the model, provider attempts, end-to-end latency, token usage, status, cost, and routing attempt traces.
• Response metadata indicates which provider ultimately fulfilled the request.
7 Spend & Budget Controls
• Set spending limits and budgets scoped to teams, projects, API keys, or team members.
• New requests using system credentials are automatically rejected once an applicable budget is reached (BYOK usage is metered separately).
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Quick Examples
Vercel AI SDK
import { generateText } from 'ai';
const { text } = await generateText({
model: 'openai/gpt-4o', // or desired model ID
prompt: 'Explain AI Gateway in one sentence.',
});
console.log(text);
cURL (OpenAI Chat Completions Interface)
curl https://ai-gateway.vercel.sh/v1/chat/completions \
-H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o",
"messages": [
{
"role": "user",
"content": "Explain AI Gateway in one sentence."
}
]
}'
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sources
• Source file: /vercel/ai/ai-gateway.md
• Additional bundle references: /vercel/deploy/cli.md, /vercel/platform/rest-api.md
• Canonical documentation: https://vercel.com/docs/ai-gateway (Fetched: https://vercel.com/docs/ai-gateway.md)
```