Configuring AI Provider Keys

This page explains how to configure Mito Data Copilot to use your own AI API keys instead of the Mito server.

By default, Mito uses our server to send AI requests to the model provider. If instead you want to use your own AI API keys, you can set the following configuration options.

Available Model Providers

Mito supports the following AI models through environment variables:

OpenAI

  • Set OPENAI_API_KEY to your OpenAI API key

  • When using OpenAI, Mito will automatically use gpt-4.1.

Claude (Anthropic)

  • Set CLAUDE_MODEL to specify the model (e.g., "claude-3-7-sonnet-latest").

  • Set CLAUDE_API_KEY to your Anthropic API key

Gemini (Google)

  • Set GEMINI_MODEL to specify the model (eg., "gemini-2.0-flash").

  • Set GEMINI_API_KEY to your Google API key

Ollama (Self-hosted)

  • Set OLLAMA_MODEL to specify the model

  • Set OLLAMA_BASE_URL to your Ollama server URL (e.g., "http://localhost:11434/v1")

Azure OpenAI

If you are a Mito Enterprise user, you can configure Mito to use a Azure OpenAI endpoint instead. If you have questions about Mito Enterprise, please contact [email protected].

  • Set AZURE_OPENAI_API_KEY to your Azure OpenAI API key

  • Set AZURE_OPENAI_API_VERSION to specify the API version

  • Set AZURE_OPENAI_ENDPOINT to your Azure OpenAI endpoint URL

  • Set AZURE_OPENAI_MODEL to specify the deployed model name

Setting Up Environment Variables

Important: Environment variables must be set before launching JupyterLab, as they are read when the Mito server extension initializes during startup.

Method 1: System Environment Variables

Set environment variables at the system level before starting JupyterLab:

On Windows:

set GEMINI_API_KEY=your-api-key-here
set GEMINI_MODEL=gemini-2.0-flash

On macOS/Linux:

export GEMINI_API_KEY=your-api-key-here
export GEMINI_MODEL=gemini-2.0-flash

Method 2: .env File with jupyter_server_config.py

  1. Create a .env file in your Jupyter config directory:

GEMINI_API_KEY=your-api-key-here
GEMINI_MODEL=gemini-2.0-flash
  1. Create or modify your jupyter_server_config.py file to load these variables on startup:

import os
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv('/path/to/your/.env')

Method 3: Permanent Environment Variables

Add the environment variables to your shell's configuration file for permanent setup:

On Windows:

Add environment variables through System Properties > Environment Variables.

On macOS/Linux:

Add to your .bashrc, .zshrc, or equivalent:

export GEMINI_API_KEY=your-api-key-here
export GEMINI_MODEL=gemini-2.0-flash

Data Protection Considerations

Remember that when using external AI providers:

  • Private data in dataframe names, column headers, or the first five rows of data might be shared with the AI provider

  • To maximize data protection, Mito Enterprise users can connect to a self-hosted model

Last updated

Was this helpful?