Skip to main content

v0 Integration

Oxygen integrates with v0.dev to enable AI-powered data application creation. The v0 integration allows agents to generate interactive dashboards and visualizations using natural language.

Overview

The v0 integration provides a create_v0_app tool that agents can use to build data applications. When an agent needs to create a visualization or dashboard, it can leverage v0’s generative UI capabilities to create interactive React components that query data using the Oxygen SDK.

Prerequisites

Before using the v0 integration, you need:
  1. Oxygen CLI: Install the Oxygen CLI by following the installation guide
  2. v0 API Key: Get your API key from v0.dev/chat/settings/keys

Configuration

1. Set up Environment Variable

Export your v0 API key as an environment variable:
To persist this across terminal sessions, add it to your shell profile:

2. Configure Oxygen API URL (Optional)

When v0 creates data applications, they need to connect to your Oxygen API to query data using the Oxygen SDK. By default, the integration assumes your Oxygen API is running at http://127.0.0.1:3000/api (local development).
Important: Use 127.0.0.1 instead of localhost for local development. v0 blocks URLs without dots in the hostname for security reasons, so localhost will not work.
If you’re running the Oxygen web app on a different host or port, set the OXY_API_URL environment variable:
To persist this across terminal sessions:

3. Configure Agent with v0 Tool

In your agent configuration file (e.g., v0.agent.yml), add the create_v0_app tool:
You can see a complete example in crates/app/demo_project/v0.agent.yml.

Running Oxygen with v0 Integration

Quick Start

  1. Set up environment variables:
  1. Navigate to a project with v0-enabled agent configuration:
  1. Run the agent:
  1. Interact with the agent:
The agent will:
  • Analyze your request
  • Query the data using SQL
  • Persist the results
  • Generate a v0 app with interactive visualizations
  • Return a URL to your data application

How It Works

Data App Creation Flow

When you ask the agent to create a data application:
  1. Data Preparation: The agent uses execute_sql tool with the persist flag to prepare data tables
  2. Schema Definition: The agent formats table schemas for v0:
  3. v0 Prompt: The agent sends a detailed prompt to v0 with:
    • Your visualization requirements
    • Available data tables and their schemas
    • Instructions to use Oxygen SDK for querying
  4. Environment Configuration: The integration automatically configures the v0 project with:
    • OXY_URL: Your Oxygen API endpoint (from OXY_API_URL env var)
    • OXY_PROJECT_ID: Your current project ID
    • OXY_API_KEY: Optional API key for authentication
  5. App Generation: v0 generates a React application with the Oxygen SDK integrated
  6. Deployment: The app is deployed and a URL is returned

Example Interaction

Best Practices

1. Persist Data Before Creating Apps

Always use the persist flag when executing SQL for v0 apps:

2. Provide Clear Schema Information

Help v0 understand your data by providing clear column names and types:

3. Include Oxygen SDK Instructions

When prompting v0, always mention using the Oxygen SDK:

Troubleshooting

”V0_API_KEY environment variable not set”

Solution: Make sure you’ve exported the V0_API_KEY environment variable:
Verify it’s set:

v0 app not using Oxygen SDK

Solution: Ensure your agent’s system instructions include guidance to prompt v0 with SDK usage instructions. See the example in crates/app/demo_project/v0.agent.yml:108.

Data not loading in the app

Solution: Make sure data was persisted correctly before calling v0_app. Check that:
  1. execute_sql was called with persist: true
  2. The file paths in the v0 prompt match the persisted table locations
  3. The schema information is accurate

v0 app cannot connect to Oxygen API

Problem: The generated v0 app shows connection errors or cannot fetch data from the Oxygen SDK. Solution: Verify that the OXY_API_URL environment variable is set correctly:
  1. Check if OXY_API_URL is set:
  2. For local development with Oxygen web app, ensure it matches where your web app is running:
  3. For production deployments, use your public Oxygen instance URL:
  4. Make sure the Oxygen web app is actually running at the specified URL
  5. Verify you’re using 127.0.0.1 instead of localhost for local development (v0 security restriction)
  6. Check that the v0 app can reach the Oxygen API (firewall, CORS, network access)

Example Agent Configuration

Here’s a minimal agent configuration with v0 integration:

Next Steps

Reference