Prime Agent LLM Providers and API Key Configuration: A Complete Developer Guide
Prime Agent supports nine major LLM providers including OpenAI, Anthropic, Google Gemini, Mistral, Azure OpenAI, and Amazon Bedrock, with API keys configured via environment variables defined in packages/ai/src/env-api-keys.ts.
Prime Agent by PrimeIntellect-ai provides a unified interface for multiple large language model providers. Understanding which Prime Agent LLM providers are available and how to authenticate them is essential for building agentic applications. The system registers all providers at startup through a centralized registry that maps API identifiers to streaming implementations.
Supported LLM Providers in Prime Agent
Prime Agent registers all built-in providers at startup through the registerBuiltInApiProviders() function in packages/ai/src/providers/register-builtins.ts. Each provider maps to a specific API identifier and implements lazy-loaded streaming handlers.
OpenAI and Azure OpenAI
Prime Agent includes four distinct OpenAI-related providers:
openai-completions(lines 49-55): Targets the OpenAI completions endpoint for models likegpt-4o-miniopenai-responses(lines 61-66): Uses the OpenAI chat-completion API for GPT-4 and similar modelsopenai-codex-responses(lines 73-77): Specialized provider for OpenAI Codex code-generation modelsazure-openai-responses(lines 67-71): Connects to Azure-hosted OpenAI service deployments
Anthropic Claude
anthropic-messages (lines 42-47): Provides access to Anthropic's Claude chat models through the Messages API.
Google AI Platforms
google-generative-ai(lines 78-84): Connects to Google Gemini via the Generative AI APIgoogle-vertex(lines 85-89): Supports Google Vertex AI for enterprise Gemini deployments
Mistral AI
mistral-conversations (lines 56-60): Implements streaming chat with Mistral-AI models.
Amazon Bedrock
bedrock-converse-stream (lines 90-95): Enables streaming conversations with Amazon Bedrock models, including Claude-like models hosted on AWS.
How to Configure API Keys
Prime Agent resolves API keys through environment variables mapped in packages/ai/src/env-api-keys.ts. The getEnvApiKey() function orchestrates lookup via findEnvKeys() and getApiKeyEnvVars() (lines 95-138).
Environment Variable Mappings
| Provider | Environment Variable |
|---|---|
openai |
OPENAI_API_KEY |
azure-openai-responses |
AZURE_OPENAI_API_KEY |
google |
GEMINI_API_KEY |
google-vertex |
GOOGLE_CLOUD_API_KEY |
anthropic |
ANTHROPIC_OAUTH_TOKEN or ANTHROPIC_API_KEY |
mistral |
MISTRAL_API_KEY |
amazon-bedrock |
AWS credential chain (see below) |
For OpenAI specifically, the provider reads process.env.OPENAI_API_KEY and throws an error if missing (see openai-responses.ts lines 177-182).
AWS Bedrock Configuration
Amazon Bedrock uses the AWS credential chain rather than a single API key. The system checks multiple sources including AWS_PROFILE, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_BEARER_TOKEN_BEDROCK (lines 87-108 in env-api-keys.ts).
Programmatic API Key Passing
You can bypass environment variables by passing an apiKey property in the options object. Most providers check options?.apiKey?.trim() first, as shown in google-vertex.ts line 407.
Configuration Examples
Set environment variables before launching:
export OPENAI_API_KEY="sk-your-openai-key"
export AZURE_OPENAI_API_KEY="your-azure-key"
export GEMINI_API_KEY="your-gemini-key"
export MISTRAL_API_KEY="your-mistral-key"
export ANTHROPIC_API_KEY="your-anthropic-key"
export GOOGLE_CLOUD_API_KEY="your-vertex-key"
Usage Code Examples
OpenAI Completions with Explicit Key
import { streamOpenAICompletions } from "@earendil-works/pi-ai";
const model = {
api: "openai-completions",
id: "gpt-4o-mini",
provider: "openai"
};
const context = {
messages: [{ role: "user", content: "Write a haiku." }]
};
for await (const event of streamOpenAICompletions(
model,
context,
{ apiKey: process.env.OPENAI_API_KEY }
)) {
if (event.type === "text") console.log(event.text);
}
Amazon Bedrock with AWS Credentials
import { streamSimpleBedrockLazy as streamBedrock } from "@earendil-works/pi-ai";
const model = {
api: "bedrock-converse-stream",
id: "anthropic.claude-v2",
provider: "amazon-bedrock"
};
const ctx = {
messages: [{ role: "user", content: "Summarize the latest news." }]
};
for await (const ev of streamBedrock(model, ctx)) {
if (ev.type === "text") console.log(ev.text);
}
Key Implementation Files
packages/ai/src/providers/register-builtins.ts: Provider registration and lazy stream wiringpackages/ai/src/env-api-keys.ts: Environment variable mapping and resolution logicpackages/ai/src/providers/openai-responses.ts&openai-completions.ts: OpenAI key access patternspackages/ai/src/providers/amazon-bedrock.ts: AWS credential chain implementationpackages/ai/src/providers/google-vertex.ts: ADC and explicit key fallback handling
Summary
- Prime Agent supports nine LLM providers via
registerBuiltInApiProviders()inregister-builtins.ts - API keys resolve through environment variables mapped in
env-api-keys.ts - OpenAI, Anthropic, Google, Mistral, and Azure use specific
*_API_KEYvariables - Amazon Bedrock uses AWS credential chain variables instead of single keys
- Pass
apiKeyin options objects to override environment variables
Frequently Asked Questions
Which environment variable does Prime Agent use for OpenAI?
Prime Agent checks OPENAI_API_KEY for OpenAI providers, as defined in packages/ai/src/env-api-keys.ts and accessed in openai-responses.ts lines 177-182.
Can I use Amazon Bedrock without explicit API keys?
Yes. Amazon Bedrock uses AWS credential chain variables such as AWS_PROFILE, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY rather than a single API key, as implemented in packages/ai/src/env-api-keys.ts lines 87-108.
How do I configure Google Vertex AI authentication?
Google Vertex AI supports either the GOOGLE_CLOUD_API_KEY environment variable or Application Default Credentials (ADC), with explicit keys taking precedence when passed via the apiKey options parameter (see google-vertex.ts line 407).
What happens if an API key is missing?
Prime Agent throws an error during provider initialization if a required environment variable is missing, as demonstrated in the OpenAI responses provider which validates process.env.OPENAI_API_KEY before making requests.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →