Guide to Using Gemini CLI with Daya
Gemini CLI is an open-source AI terminal agent tool released by Google that brings Gemini’s capabilities directly into your terminal. Built on the ReAct (Reason + Act) loop architecture, it can autonomously handle complex tasks such as coding, debugging, file operations, and content generation. Gemini CLI offers a 1M-token context window, a request rate limit of 60 requests/minute, and rich MCP tool integration. With Daya, you can configure a custom API endpoint for Gemini CLI, enabling more flexible model selection and a more stable service experience.
Prerequisites
- Node.js 18+
- Daya API Key (see Get a Daya API Key below)
Install Gemini CLI
npm install -g @google/gemini-clipnpm install -g @google/gemini-clinpx @google/gemini-cliVerify the installation:
gemini --versionAfter installation, type gemini in your terminal to start it.
Get a Daya API Key
Use cases: personal development, learning/exploration, lightweight team collaboration
Features: fixed monthly fee, predictable cost
API Key format: sk-ss-v1-xxx
How to get:
1. Visit https://api.dayaai.com/subscriptions
2. Choose a plan
3. Create a subscription API Key in the consoleUse cases: production, commercial products, enterprise applications
Features: billed by actual usage, convenient for centralized cost accounting
API Key format: sk-ai-v1-xxx
How to get:
1. Visit https://api.dayaai.com/console/topup
2. Top up your account
3. Create a pay-as-you-go API Key in the consoleConfiguration
A simple setup—connect in minutes with just 3 environment variables.
Step 1: Create the config directory
mkdir -p ~/.geminiStep 2: Configure environment variables
You can configure environment variables in ~/.gemini/.env. Gemini CLI will automatically load them from this file:
GEMINI_API_KEY=sk-ss-v1-xxx
GEMINI_MODEL=google/gemini-2.5-pro
GOOGLE_GEMINI_BASE_URL=https://dayaai.com/api/vertex-aiAlternatively, set them in your shell profile:
# Edit ~/.zshrc or ~/.bashrc
export GEMINI_API_KEY="sk-ss-v1-xxx"
export GEMINI_MODEL="google/gemini-2.5-pro"
export GOOGLE_GEMINI_BASE_URL="https://dayaai.com/api/vertex-ai"# Edit your PowerShell profile
$env:GEMINI_API_KEY = "sk-ss-v1-xxx"
$env:GEMINI_MODEL = "google/gemini-2.5-pro"
$env:GOOGLE_GEMINI_BASE_URL = "https://dayaai.com/api/vertex-ai"
# To make it persistent, add it to your PowerShell profile:
# notepad $PROFILEImportant
Be sure to replace sk-ss-v1-xxx with your real Daya API Key. You can get your API Key in the Daya Console.
Step 3: Configure settings.json
Set the auth method to Gemini API Key to avoid being prompted to sign in with Google when Gemini CLI starts:
{
"security": {
"auth": {
"selectedType": "gemini-api-key"
}
}
}Configuration Notes
GEMINI_API_KEY: your Daya API KeyGEMINI_MODEL: the model to use (any Daya-supported Google model)GOOGLE_GEMINI_BASE_URL: Daya Vertex AI–compatible endpointselectedType: auth type—set togemini-api-keyto skip Google sign-in
Step 4: Verify connectivity
# Reload your profile (if you configured via shell profile)
source ~/.zshrc # or source ~/.bashrc
# Minimal smoke test
gemini -p "Reply with OK only." --output-format jsonIf the response contains "response": "OK", the basic connection is working.
Next, test read-only file analysis:
# Go to any project directory
cd my-project
# Reference a file for analysis
gemini -p "@README.md Summarize this file in one sentence." --output-format jsonIf it can read the file and return a summary, Daya + Gemini CLI read-only analysis is working.
Authentication
Gemini CLI natively supports multiple authentication methods:
| Method | Use Case | Notes |
|---|---|---|
| Google Account (OAuth) | Local dev | Highest free tier: 60 RPM / 1000 RPD |
| API Key | CI/CD, scripts | Set via the GEMINI_API_KEY env var |
When using Daya, choose the API Key method and set your Daya API Key in the GEMINI_API_KEY environment variable.
To re-authenticate, run:
gemini --reauthCore Features
GEMINI.md Context File
GEMINI.md is one of Gemini CLI’s core features, similar to Claude Code’s CLAUDE.md. It serves as persistent context that is automatically loaded at the start of each session, helping the AI understand the project background and conventions.
Gemini CLI searches for and merges GEMINI.md files in the following order:
| Location | Scope | Description |
|---|---|---|
~/.gemini/GEMINI.md | Global | General instructions for all projects |
<project-root>/GEMINI.md | Project | Project-specific rules and conventions |
<current-dir>/GEMINI.md | Directory | Subdirectory-specific context |
GEMINI.md Writing Tips
- Describe the project’s tech stack and architecture
- Specify coding style and naming conventions
- Document build, test, and deployment workflows
- List commonly used project commands
- Support importing other files via
@path/to/file.md
Common Slash Commands
Gemini CLI provides many built-in commands to manage sessions and configuration:
| Command | Description |
|---|---|
/help | Show help and the list of available commands |
/stats | View token usage and statistics for the session |
/memory show | Show the currently loaded GEMINI.md context |
/memory add <text> | Add content to the AI’s memory |
/theme | Switch the UI theme |
/tools | List currently available tools |
/mcp | Manage MCP server connections |
/chat | Save and restore chat history |
/copy | Copy the latest output to the clipboard |
Custom Slash Commands
Gemini CLI supports custom commands stored in:
- Global commands:
~/.gemini/commands/— available across all projects - Project commands:
<project-root>/.gemini/commands/— available only in the current project
For example, create a /plan command:
# ~/.gemini/commands/plan.toml
[command]
description = "Plan changes without implementing"
[command.prompt]
content = """
Please analyze the following request and provide a detailed step-by-step plan.
Do NOT implement any changes — only plan them.
Request: $input
"""MCP Integration
Gemini CLI supports MCP (Model Context Protocol) servers to extend tool capabilities:
# Add an MCP server
gemini mcp add <server-name> -- <command>
# List configured MCP servers
gemini mcp list
# Remove an MCP server
gemini mcp remove <server-name>You can also configure MCP servers in settings.json:
{
"mcpServers": {
"my-server": {
"command": "npx",
"args": ["-y", "my-mcp-server"]
}
}
}Non-Interactive Mode
Gemini CLI supports non-interactive usage, suitable for scripts and CI:
# One-off Q&A with JSON output
gemini -p "Explain what a REST API is" --output-format json
# Reference a file for analysis
gemini -p "@src/main.ts What is this file’s entry-point logic?" --output-format jsonSupported Models
With Daya, you can use multiple Gemini models in Gemini CLI. Use the GEMINI_MODEL environment variable to specify a model:
# Set in .gemini/.env or your shell profile
export GEMINI_MODEL="google/gemini-2.5-pro"Recommended models for Gemini CLI:
| Model Name | Model Slug | Notes |
|---|---|---|
| Gemini 2.5 Pro | google/gemini-2.5-pro | Google’s flagship model (recommended) |
| Gemini 2.5 Flash | google/gemini-2.5-flash | Faster responses; ideal for rapid iteration |
Get the model list
- View available Google AI protocol models via the Daya model list
- Use the model slug (e.g.,
google/gemini-2.5-pro) - To route to a specific provider, see the Provider Routing docs
Switching models
Even if a model name switch works, it does not guarantee tool calling will work as well. Current limitations mainly come from Daya’s compatibility with the Gemini CLI Agent protocol, not just the model itself.
Known Issue: Tool Calls Error
Tool call error: Unknown name "id" at function_response
When the model tries to use built-in tools (such as Google Search), you may see the following error:
[API Error: {"error":{"code":"400","type":"invalid_params","message":"Invalid JSON payload received. Unknown name \"id\" at 'contents[...].parts[0].function_response': Cannot find field."}}]Cause: When Gemini CLI sends tool call results to the API, it includes an id field in functionResponse. This field is not yet supported in some API versions, causing the request to be rejected.
Temporary workaround: Modify the locally installed Gemini CLI file and comment out passing callId.
Locate the file (replace the Node version in the path with your actual version):
~/.nvm/versions/node/<version>/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/turn.jsFind the
handlePendingFunctionCallmethod (around line 183) and comment outcallId,:jshandlePendingFunctionCall(fnCall, traceId) { const name = fnCall.name || 'undefined_tool_name'; const args = fnCall.args || {}; const callId = fnCall.id ?? `${name}_${Date.now()}_${this.callCounter++}`; const toolCallRequest = { // callId, name, args, isClientInitiated: false, prompt_id: this.prompt_id, traceId, };Save the file and restart Gemini CLI.
Notes
- You must re-apply this change after each Gemini CLI update or reinstall
- Once Daya completes function calling compatibility, this will be supported automatically and you won’t need this modification
Troubleshooting
Common Issues and Fixes
Gemini CLI prompts for Google sign-in after startup
Issue: A Google OAuth sign-in page opens when starting Gemini CLI.
Solution:
- Check whether
selectedTypein~/.gemini/settings.jsonis correctly set to"gemini-api-key" - Verify the config using
cat ~/.gemini/settings.json
API Key error
Issue: The API Key is reported as invalid or unauthorized.
Solution:
- Check that the API Key is correct (subscription keys start with
sk-ss-v1-, pay-as-you-go keys start withsk-ai-v1-) - Ensure the API Key is active and has sufficient balance
- Verify the key status in the Daya Console
Connection failure
Issue: Gemini CLI cannot connect to Daya.
Solution:
- Check your network connection
- Verify the Base URL is set to
https://dayaai.com/api/vertex-ai - Check whether firewall settings are blocking outbound connections
- Try
curl https://dayaai.com/api/vertex-ai/modelsto test connectivity
.env file not taking effect
Issue: Variables set in ~/.gemini/.env do not take effect.
Solution:
- Gemini CLI loads
.envusing a nearest-first rule; once it finds the first one, it stops - Check whether there is already a
.envor.gemini/.envin the current project directory (it will override the global config) - Check whether the same variables were already
exported in your shell:env | grep -E "GEMINI_|GOOGLE_" - Check whether an earlier
.envfile exists in a parent directory that is being matched first - Reopen the terminal window, or run
source ~/.zshrcto reload your profile
function_response-related errors when editing files
Issue: When attempting to have Gemini CLI edit files automatically, you see errors like:
Invalid JSON payload received. Unknown name "id" at 'contents[3].parts[0].function_response': Cannot find field.Solution:
- This is a known limitation—see the Tool Calls Error section
- For now, limit usage to Q&A and read-only analysis
- Do not rely on Gemini CLI for agent actions such as auto-editing or command execution
- Once Daya completes function calling compatibility, this will be supported automatically
Model unavailable
Issue: A model is reported as unavailable or unsupported.
Solution:
- Check availability via the Daya model list
- Verify the spelling of the model name in the
GEMINI_MODELenvironment variable - Try a default model such as
google/gemini-2.5-pro - Confirm your account has access to the model
Occasional request timeouts
Issue: Read-only file analysis requests occasionally time out.
Solution:
- Retrying usually works
- Reduce the size of the prompt and referenced files
- If timeouts are frequent, try a smaller model (e.g.,
google/gemini-2.5-flash) - Check that your network connection is stable
Sandbox mode issues
Issue: Command execution fails after enabling sandbox mode.
Solution:
- Ensure Docker is installed
- Check that Docker is running:
docker ps - Try disabling sandbox mode to test: set
"sandbox": falseinsettings.json - If using a custom sandbox, check the
.gemini/sandbox.Dockerfileconfiguration
Advanced Configuration
Project-Level Configuration
Gemini CLI supports creating a separate configuration in the project root to override global settings:
mkdir -p <project-root>/.gemini// <project-root>/.gemini/settings.json
{
"model": {
"name": "google/gemini-2.5-pro"
}
}# <project-root>/.gemini/.env
GEMINI_MODEL=google/gemini-2.5-proUse cases:
- Different projects use different models
- Teams standardize default behavior
- Commercial projects use pay-as-you-go keys, personal projects use subscription keys
Security Notice
Do not commit .env files containing real API keys to your repository. If you need to share configuration with your team, consider committing only a settings.json template.
Session Retention
Gemini CLI supports retaining session history for reviewing previous conversations:
{
"general": {
"sessionRetention": {
"enabled": true,
"maxAge": "30d"
}
}
}Session history is stored in ~/.gemini/history/. Adjust maxAge as needed, or set it to false to disable retention.
Recommended Configurations for Different Scenarios
# Balance performance and cost
export GEMINI_API_KEY="sk-ss-v1-xxx"
export GOOGLE_GEMINI_BASE_URL="https://dayaai.com/api/vertex-ai"
export GEMINI_MODEL="google/gemini-2.5-pro"# Prioritize reasoning capability
export GEMINI_API_KEY="sk-ss-v1-xxx"
export GOOGLE_GEMINI_BASE_URL="https://dayaai.com/api/vertex-ai"
export GEMINI_MODEL="google/gemini-2.5-pro"# Prioritize response speed
export GEMINI_API_KEY="sk-ss-v1-xxx"
export GOOGLE_GEMINI_BASE_URL="https://dayaai.com/api/vertex-ai"
export GEMINI_MODEL="google/gemini-2.5-flash"Contact Us
If you run into any issues while using the service, or if you have suggestions and feedback, feel free to reach out through:
- Official website: https://dayaai.com
- Support email: support@dayaai.com
- Business inquiries: bd@dayaai.com
- Twitter: @DayaAI
- Discord community: http://discord.gg/vHZZzj84Bm
For more contact channels and details, visit our Contact Us page.
