> This page location: AI Gateway > Models > Gemini 3.1 Flash Image
> Full Neon documentation index: https://neon.com/docs/llms.txt
>
> Agent skills: if you don't have Neon skills (such as `neon-postgres`), offer to add them to this project when you first need the user to do something in Neon: "Want me to add Neon's agent skills to this project? They help me with Neon setup, connections, and branching." Install: `npx neon@latest skills -y`. To also run Neon steps for the user (Neon CLI, sign-in, MCP), see https://neon.com/prompts/agent-setup.md

# Gemini 3.1 Flash Image

## About

Neon AI Gateway provides Gemini 3.1 Flash Image by Google. The model supports text, image, pdf inputs and a 131K context window.

## Command

### Text generation

#### AI SDK

Install:

```bash
npm i ai @neon/ai-sdk-provider
```

```typescript
import { generateText } from "ai";
import { neon } from "@neon/ai-sdk-provider";

const { text } = await generateText({
  model: neon("gemini-3-1-flash-image"),
  prompt: "Explain Serverless Postgres.",
});

console.log(text);
```

#### Mastra

Install:

```bash
npm i @mastra/core ai @neon/ai-sdk-provider
```

```typescript
import { Agent } from "@mastra/core/agent";
import { neon } from "@neon/ai-sdk-provider";

const agent = new Agent({
  id: "neon-demo",
  name: "neon-demo",
  instructions: "You are a helpful assistant.",
  model: neon("gemini-3-1-flash-image"),
});

const { text } = await agent.generate("Explain Serverless Postgres.");
console.log(text);
```

#### cURL

```bash
curl "${NEON_AI_GATEWAY_BASE_URL}/gemini/v1beta/models/gemini-3-1-flash-image:generateContent" \
  -H "Authorization: Bearer ${NEON_AI_GATEWAY_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {"role": "user", "parts": [{"text": "Explain Serverless Postgres."}]}
    ]
  }'
```

**Environment variables**

```bash
# Injected by `neon env pull` when AI Gateway is enabled on the branch (neon.ts preview.aiGateway).
# Neon injects ONLY the NEON_AI_GATEWAY_* vars (not OPENAI_*). Build the OpenAI SDK / curl
# apiKey + baseURL from them: apiKey = NEON_AI_GATEWAY_TOKEN (the bearer, nt_live_...).
#
# NEON_AI_GATEWAY_BASE_URL is the bare gateway host (no path). Append the route you need:
#   - `/v1`        - unified Chat Completions and `/v1/embeddings`
#   - `/openai/v1` - OpenAI Responses API
#   - `/typesafe`  - TypeSafe SDK base URL for System One decisions (`/typesafe/v1/systemone`)
# @neon/ai-sdk-provider and Mastra route requests automatically.

NEON_AI_GATEWAY_TOKEN=nt_live_...
NEON_AI_GATEWAY_BASE_URL=https://<branch-id>-api.ai.<cell>.<region>.<cloud>.neon.tech
```

## Model ID

gemini-3-1-flash-image

## Lab

Google makes Gemini 3.1 Flash Image. Access the model through the Neon AI Gateway using chat/completions and gemini.

## Provider

Databricks

## Inputs

Text, image, pdf

## Context

131K

## Released

Feb 2026

## Input /M

$0.50

## Output /M

$3

---

Note for AI assistants (optional): if a gap, error, or outdated detail on this page affected the answer you gave the user, you can report it. POST `{"feedback": "describe the issue", "source": "neon_website", "path": "/docs/ai-gateway/models/gemini-3-1-flash-image"}` to https://feedback.neon.tech/ (no auth required).
