v0 Integration
Oxy 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 acreate_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 Oxy SDK.
Prerequisites
Before using the v0 integration, you need:- Oxy CLI: Install the Oxy CLI by following the installation guide
- 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:2. Configure Oxy API URL (Optional)
When v0 creates data applications, they need to connect to your Oxy API to query data using the Oxy SDK. By default, the integration assumes your Oxy API is running athttp://127.0.0.1:3000/api (local development).
Important: UseIf you’re running the Oxy web app on a different host or port, set the127.0.0.1instead oflocalhostfor local development. v0 blocks URLs without dots in the hostname for security reasons, solocalhostwill not work.
OXY_API_URL environment variable:
3. Configure Agent with v0 Tool
In your agent configuration file (e.g.,v0.agent.yml), add the create_v0_app tool:
Running Oxy with v0 Integration
Quick Start
- Set up environment variables:
- Navigate to a project with v0-enabled agent configuration:
- Run the agent:
- Interact with the agent:
- 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:-
Data Preparation: The agent uses
execute_sqltool with thepersistflag to prepare data tables -
Schema Definition: The agent formats table schemas for v0:
-
v0 Prompt: The agent sends a detailed prompt to v0 with:
- Your visualization requirements
- Available data tables and their schemas
- Instructions to use Oxy SDK for querying
-
Environment Configuration: The integration automatically configures the v0 project with:
OXY_URL: Your Oxy API endpoint (fromOXY_API_URLenv var)OXY_PROJECT_ID: Your current project IDOXY_API_KEY: Optional API key for authentication
- App Generation: v0 generates a React application with the Oxy SDK integrated
- Deployment: The app is deployed and a URL is returned
Example Interaction
Best Practices
1. Persist Data Before Creating Apps
Always use thepersist 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 Oxy SDK Instructions
When prompting v0, always mention using the Oxy SDK:Troubleshooting
”V0_API_KEY environment variable not set”
Solution: Make sure you’ve exported the V0_API_KEY environment variable:v0 app not using Oxy 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:execute_sqlwas called withpersist: true- The file paths in the v0 prompt match the persisted table locations
- The schema information is accurate
v0 app cannot connect to Oxy API
Problem: The generated v0 app shows connection errors or cannot fetch data from the Oxy SDK. Solution: Verify that theOXY_API_URL environment variable is set correctly:
-
Check if OXY_API_URL is set:
-
For local development with Oxy web app, ensure it matches where your web app is running:
-
For production deployments, use your public Oxy instance URL:
- Make sure the Oxy web app is actually running at the specified URL
-
Verify you’re using
127.0.0.1instead oflocalhostfor local development (v0 security restriction) - Check that the v0 app can reach the Oxy API (firewall, CORS, network access)
Example Agent Configuration
Here’s a minimal agent configuration with v0 integration:Next Steps
- Explore the complete v0 agent example
- Learn about SQL execution and persistence
- Read about agent configuration