OpenAI Key Request While Using Other Models
Agno defaults to OpenAI for models and embedders. Set both explicitly to remove the OPENAI_API_KEY requirement.
If you see a request for an OpenAI API key but haven't configured OpenAI, it's because Agno uses OpenAI by default in two places:
- The default model when
Agenthas nomodelset - The default embedder (
OpenAIEmbedder) for vector databases
Quick fix: Configure a Different Model
Specify the model explicitly. Without one, the agent defaults to OpenAIResponses with gpt-5.4, which requires OPENAI_API_KEY.
Install the Google dependencies and set its API key:
uv pip install "agno[google,postgres,pgvector]"
export GOOGLE_API_KEY="your-google-api-key"For example, to use Google's Gemini instead of OpenAI:
from agno.agent import Agent
from agno.models.google import Gemini
agent = Agent(
model=Gemini(id="gemini-3.5-flash"),
markdown=True,
)
# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story.")See Models for the full provider list.
Quick fix: Configure a Different Embedder
The same applies to embeddings. To use an embedder other than OpenAIEmbedder, configure it explicitly.
For example, use GeminiEmbedder with the same GOOGLE_API_KEY. The Knowledge example also needs a reachable PostgreSQL database at the shown URL with pgvector available:
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.pgvector import PgVector
from agno.knowledge.embedder.google import GeminiEmbedder
# Embed a sentence
embeddings = GeminiEmbedder().get_embedding("The quick brown fox jumps over the lazy dog.")
# Print the embeddings and their dimensions
print(f"Embeddings: {embeddings[:5]}")
print(f"Dimensions: {len(embeddings)}")
# Use an embedder in a knowledge base
knowledge = Knowledge(
vector_db=PgVector(
db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
table_name="gemini_embeddings",
embedder=GeminiEmbedder(),
),
max_results=2,
)See Embedders for the available options.