Make create-onchain-agent templates LLM provider-agnostic. Closes #1106#1108
Open
0xshae wants to merge 4 commits intocoinbase:mainfrom
Open
Make create-onchain-agent templates LLM provider-agnostic. Closes #1106#11080xshae wants to merge 4 commits intocoinbase:mainfrom
0xshae wants to merge 4 commits intocoinbase:mainfrom
Conversation
replace hardcoded OpenAI imports and OPENAI_API_KEY with configurable env vars (AI_API_KEY, AI_PROVIDER_URL, AI_MODEL) that support any OpenAI-compatible provider including OpenRouter, Groq, and Together. both Vercel AI SDK and Langchain templates now use createOpenAI/ChatOpenAI with configurable baseURL. backward compatible with existing OPENAI_API_KEY.
…c and google support add getModel/getLLM factory pattern that supports four provider modes: - openai: native OpenAI API (default) - anthropic: native Anthropic/Claude API - google: native Google Gemini API - custom: any OpenAI-compatible API (OpenRouter, Groq, Ollama, etc.) controlled via env vars: AI_PROVIDER, AI_API_KEY, AI_MODEL, AI_PROVIDER_URL. adds @ai-sdk/anthropic, @ai-sdk/google, @langchain/anthropic, @langchain/google-genai as template dependencies.
…nfig leverage the fact that all major LLM providers (Anthropic, Google, OpenRouter, Groq, Ollama) now support the OpenAI chat completions API format. instead of importing each provider's SDK, use the existing createOpenAI/ChatOpenAI with a configurable baseURL. this means: - zero new dependencies (uses @ai-sdk/openai and @langchain/openai already installed) - zero factory pattern or switch statements - switch providers by setting AI_BASE_URL in .env - backward compatible with OPENAI_API_KEY env vars: AI_API_KEY, AI_BASE_URL, AI_MODEL
🟡 Heimdall Review Status
|
MVPuknowme
reviewed
Apr 15, 2026
MVPuknowme
reviewed
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Make
create-onchain-agenttemplates LLM provider-agnostic.Closes #1106
The templates currently hardcode
openai("gpt-4o-mini")andOPENAI_API_KEY. This change replaces the hardcoded singleton withcreateOpenAI({ apiKey, baseURL })/new ChatOpenAI({ apiKey, configuration: { baseURL } }), configured via environment variables.Since all major LLM providers now support the OpenAI-compatible API format, this lets developers configure any provider seamlessly via
.env.localwithout needing to edit the scaffolded codebase.Env vars added:
AI_API_KEY(Falls back toOPENAI_API_KEY)AI_BASE_URL(Provider's endpoint, defaults to OpenAI)AI_MODEL(Defaults togpt-4o-mini)Files changed:
templates/createAgent/framework/vercelAISDK/createAgent.tstemplates/createAgent/framework/langchain/createAgent.tstemplates/next/.../vercel-ai-sdk/create-agent.tstemplates/next/.../langchain/create-agent.tssrc/common/utils.ts(Generates.env.localcontaining universal provider examples)Tests
Since these changes modify the scaffolding templates and not runtime code, I tested by generating a new template, replacing the code with my modified templates, and routing requests to OpenRouter.
Checklist
A couple of things to include in your PR for completeness: