Welcome
This guide will help you make your first API request to Visca AI Gateway. You’ll learn how to:- Obtain your API key
- Make your first request
- Use streaming responses
- Handle errors effectively
Prerequisites: You’ll need an account at
gateway.visca.ai or a self-hosted instance. See
the Self-Host Guide for deployment options.
Step 1: Get Your API Key
1
Sign up or log in
Visit gateway.visca.ai and create an account or
log in to your existing account.
2
Navigate to API Keys
Go to the API Keys section in your dashboard.
3
Generate a new key
Click Create API Key, give it a descriptive name, and optionally set
usage limits.
4
Set environment variable
Add your API key to your environment:
bash export VISCA_API_KEY="vsk_your_api_key_here" Step 2: Install SDK (Optional)
While Visca AI Gateway is fully compatible with OpenAI’s SDKs, you can use any HTTP client. Here’s how to set up the OpenAI SDK:- Python
- JavaScript/TypeScript
- Go
- Ruby
bash pip install openai Step 3: Make Your First Request
Choose your preferred language and make your first request:Step 4: Try Streaming Responses
For real-time applications, use streaming to receive responses as they’re generated:Available Models
Visca AI Gateway supports 50+ models across multiple providers. Here are some popular options:- OpenAI
- Anthropic
- Google
- Open Source
gpt-4o- Most capable, multimodal model -gpt-4o-mini- Fast and affordable -gpt-4-turbo- Previous generation flagship -gpt-3.5-turbo- Fast and cost-effective -
dall-e-3- Image generation
To see all available models, make a request to the
/v1/models endpoint or
check your dashboard.Using Different Providers
Simply change the model name to use a different provider:Request Metadata
Track requests with custom metadata for analytics and cost allocation:Error Handling
Always implement proper error handling for production applications:Common Error Codes
| Status Code | Meaning | Solution |
|---|---|---|
| 400 | Bad Request | Check your request parameters |
| 401 | Unauthorized | Verify your API key is correct |
| 403 | Forbidden | Check API key permissions and rate limits |
| 429 | Rate Limit | Implement exponential backoff and retry |
| 500 | Server Error | Retry with exponential backoff |
| 503 | Service Unavailable | Provider is down, will auto-failover if configured |
Best Practices
Secure Your API Keys
Secure Your API Keys
- Never hardcode API keys in your source code
- Use environment variables or secrets management
- Rotate keys regularly
- Set up usage limits per key
- Use different keys for development and production
Implement Retry Logic
Implement Retry Logic
Monitor Usage and Costs
Monitor Usage and Costs
- Use the dashboard to track requests, costs, and latency - Set up alerts for unusual spending patterns - Add metadata to requests for detailed analytics - Review cost reports regularly
Optimize Performance
Optimize Performance
- Use streaming for real-time applications
- Set appropriate
max_tokensto control costs - Choose the right model for your use case (cost vs. capability)
- Enable caching for repeated queries
- Use routing strategies for optimal latency/cost
Next Steps
Intelligent Routing
Set up cost optimization and automatic failover
API Keys & Security
Configure fine-grained access control and limits
Vision & Multimodal
Work with images and vision models
Self-Host
Deploy on your own infrastructure