Prerequisites
- Bun installed
- OpenRouter API key
- Next.js project with the Better Boilerplate
Environment Setup
- Create a
.env.local
file in yourapps/server
folder:
- Install required dependencies:
Configuration
1. OpenRouter Setup
Create a new file atlib/openrouter.ts
:
Usage Example
Here’s a simple example of using the AI SDK in a server action:Next Steps
- Learn about OpenRouter Integration
- Explore AI Components
Troubleshooting
Common Issues
-
API Key Not Found
- Ensure your
.env.local
file is in the correct location - Verify the API key is correctly set
- Ensure your
-
Model Not Available
- Check if the model is supported by OpenRouter
- Verify your API key has access to the model
-
Rate Limiting
- Monitor your API usage
- Implement rate limiting in your application
Support
If you encounter any issues, please:- Check the OpenRouter Documentation
- Review the Vercel AI SDK Documentation
- Open an issue in our GitHub repository