Skip to main content

Overview

InsForge provisions an OpenRouter API key for Model Gateway projects. For new AI features, use that key directly with OpenRouter’s OpenAI-compatible API instead of the deprecated InsForge AI proxy methods. Use the InsForge dashboard to copy the active OpenRouter key, store it in OPENROUTER_API_KEY, and call OpenRouter from trusted server-side code.
Do not expose OPENROUTER_API_KEY in browser bundles. In React, Next.js, Vue, Svelte, and similar apps, put OpenRouter calls behind a backend route, server action, function, or other server-only boundary.

Installation

For local scripts, you may also want:

Environment

Create a Client

The HTTP-Referer and X-Title headers are optional OpenRouter metadata headers. Keep them if you want OpenRouter attribution and rankings for your app.

Chat Completion

Streaming

Tool Calling

Image Input

Image Generation

Use a model that supports image output and request image modality. OpenRouter supports fields that may not be in the OpenAI SDK type surface yet, so extend the request and response types locally.

Embeddings

Video Generation

OpenRouter video generation uses OpenRouter HTTP endpoints directly.

Next.js Route Example

Replace verifySessionToken with your app’s auth provider or session verifier.

Using InsForge Data with AI

Use the InsForge SDK for database, auth, storage, functions, and realtime. Use OpenRouter directly for model calls.

Legacy InsForge AI Proxy

The previous InsForge AI SDK methods are deprecated:
  • insforge.ai.chat.completions.create()
  • insforge.ai.images.generate()
  • insforge.ai.embeddings.create()
They map to backend proxy routes that still exist for compatibility, but new integrations should use OpenRouter directly. The direct path gives access to OpenRouter’s complete and evolving API surface without waiting for InsForge SDK wrapper updates.

Model Catalog

Use the InsForge dashboard or OpenRouter model catalog to choose a model. Model IDs use the provider/model format, such as openai/gpt-4o, anthropic/claude-3.5-haiku, and google/gemini-2.5-flash-image.