Private Preview
This feature is in private preview: it's not ready for production use, and it may be briefly unavailable as we deploy updates. To get access, sign up here.
The Gemini endpoint exposes the Google Gemini API through Neon AI Gateway. Use it when you're already working with the google-genai SDK and want to keep your existing code. For most use cases, the chat completions endpoint is simpler to set up and works with Gemini models via the OpenAI SDK.
Supported actions: :generateContent and :streamGenerateContent
Endpoint pattern: https://<branch-host>/ai-gateway/gemini/v1beta/models/<model>:<action>
note
Only generateContent and streamGenerateContent are supported. Requests to other actions (such as countTokens) return 404 unsupported gemini action.
Supported models
This endpoint accepts Google models only:
| Model ID | Notes |
|---|---|
gemini-3-5-flash | |
gemini-3-1-pro | |
gemini-3-1-flash-lite | |
gemini-3-pro | |
gemini-3-flash | |
gemini-2-5-pro | |
gemini-2-5-flash |
Sending a non-Google model ID returns 400 model is not available on this endpoint. Use the chat completions endpoint if you want to call Gemini models alongside other providers from the same code.
Basic request
import { GoogleGenAI } from '@google/genai';
const client = new GoogleGenAI({
apiKey: process.env.NEON_AI_GATEWAY_TOKEN,
httpOptions: {
baseUrl: `${process.env.NEON_AI_GATEWAY_BASE_URL}/ai-gateway/gemini`,
},
});
const response = await client.models.generateContent({
model: 'gemini-2-5-flash',
contents: [{ role: 'user', parts: [{ text: 'What is Neon?' }] }],
});
console.log(response.text);Streaming
const stream = await client.models.generateContentStream({
model: 'gemini-2-5-flash',
contents: [{ role: 'user', parts: [{ text: 'Explain database branching.' }] }],
});
for await (const chunk of stream) {
process.stdout.write(chunk.text ?? '');
}URL structure
The gateway uses the model ID and action directly in the URL path. The google-genai SDK constructs this automatically from the base URL and model parameter:
base_url: https://<branch-host>/ai-gateway/gemini
model: gemini-2-5-flash
action: generateContent or streamGenerateContent
→ https://<branch-host>/ai-gateway/gemini/v1beta/models/gemini-2-5-flash:generateContent
→ https://<branch-host>/ai-gateway/gemini/v1beta/models/gemini-2-5-flash:streamGenerateContentWhen calling the REST API directly, the model ID and action must appear in the path as shown above.
Error handling
| Status | Message | Cause |
|---|---|---|
400 Bad Request | unknown model | Model ID not in the catalog |
400 Bad Request | model is not available on this endpoint | Non-Google model sent to this endpoint |
400 Bad Request | missing or invalid model | No model field in request body |
404 Not Found | unsupported gemini action | Action other than generateContent or streamGenerateContent in URL |
404 Not Found | invalid gemini model path | Malformed model:action segment in URL |
For authentication, quota, and upstream errors, see Troubleshooting.
Next steps
- Models: full model catalog
- Chat completions: use Gemini models via the unified OpenAI-compatible endpoint
- Authentication: credential scopes and branch binding
Need help?
Join our Discord Server to ask questions or see what others are doing with Neon. For paid plan support options, see Support.








