coinbase / coinbase/agentkit

Feature: Make create-onchain-agent templates LLM provider-agnostic

Open
#1,106 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.3k
Forks
815
Avg merge
13h 31m
Merged PRs (30d)
2

Description

### Language Implementation

- [ ] Python
- [x] TypeScript

### Feature Type

- [ ] Action Provider Template
- [ ] Wallet Provider Template
- [ ] Framework Extension
- [ ] Core Requirements
- [x] Other

### 🚀 The feature, motivation and pitch

The `create-onchain-agent` templates currently hardcode OpenAI as the LLM provider. The generated `create-agent.ts` uses `import { openai } from "@ai-sdk/openai"` and calls `openai.chat("gpt-4o-mini")` directly, and the generated `.env.local` only includes `OPENAI_API_KEY=`.

This means a developer using any other provider (Anthropic, Google, OpenRouter, Groq, Ollama, etc.) has to open `create-agent.ts` and rewrite the model initialization before they can even run the agent.

This is unnecessary because `@ai-sdk/openai` and `@langchain/openai` — the packages already installed in the template — natively support connecting to any OpenAI-compatible API via their `baseURL` option. And all major LLM providers now expose OpenAI-compatible endpoints (Anthropic, Google Gemini, OpenRouter, Groq, Together AI, Ollama).

**Proposal:** Replace the hardcoded `openai("gpt-4o-mini")` singleton with `createOpenAI({ apiKey, baseURL })` configured via environment variables:

- `AI_API_KEY` — API key for any provider (falls back to `OPENAI_API_KEY`)
- `AI_BASE_URL` — provider's endpoint (optional, defaults to OpenAI)
- `AI_MODEL` — model identifier (optional, defaults to `gpt-4o-mini`)

The generated `.env.local` would include inline examples for all major providers, so a developer with an Anthropic key can just set two env vars and run `npm run dev` — no code changes needed.

This change:
- Adds **zero new dependencies** (uses `createOpenAI`/`ChatOpenAI` already installed)
- Is **fully backward-compatible** (falls back to `OPENAI_API_KEY` if `AI_API_KEY` is not set)
- Matches how the core `@coinbase/agentkit` library already works: fully LLM-agnostic

### Alternatives

Let developers manually edit `create-agent.ts` after scaffolding. This is the current approach but creates friction for anyone not using OpenAI.

### Additional context

The core `@coinbase/agentkit` library and all framework extensions (`agentkit-langchain`, `agentkit-vercel-ai-sdk`) are already fully LLM-agnostic. The OpenAI lock-in exists only in the scaffolding layer. The Python `create-onchain-agent` has the same issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.