Skip to main content

Prerequisites

  • Bun installed
  • OpenRouter API key
  • Next.js project with the Builder Box

Environment Setup

  1. Create a .env.local file in your apps/server folder:
  1. Install required dependencies:

Configuration

1. OpenRouter Setup

Create a new file at lib/openrouter.ts:

Usage Example

Here’s a simple example of using the AI SDK in a server action:

Next Steps

Troubleshooting

Common Issues

  1. API Key Not Found
    • Ensure your .env.local file is in the correct location
    • Verify the API key is correctly set
  2. Model Not Available
    • Check if the model is supported by OpenRouter
    • Verify your API key has access to the model
  3. Rate Limiting
    • Monitor your API usage
    • Implement rate limiting in your application

Support

If you encounter any issues, please:
  1. Check the OpenRouter Documentation
  2. Review the Vercel AI SDK Documentation
  3. Open an issue in our GitHub repository