Posts tagged "Ai-gateway"
-
OpenAI’s GPT-5.4 and GPT-5.4 Pro models are now available through Netlify’s AI Gateway and Agent Runners with zero configuration required.
Use the OpenAI SDK directly in your Netlify Functions without managing API keys or authentication. The AI Gateway handles everything automatically. Here’s an example using the GPT-5.4 model:
import OpenAI from 'openai';export default async () => {const openai = new OpenAI();const response = await openai.responses.create({model: 'gpt-5.4',input: 'Give a concise explanation of how AI works.',});return Response.json(response);};GPT-5.4 and GPT-5.4 Pro are available for all Function types and Agent Runners. You get automatic access to Netlify’s caching, rate limiting, and authentication infrastructure.
Learn more in the AI Gateway documentation and Agent Runners documentation.
-
Google’s Gemini 3.1 Flash Lite Preview is now available through AI Gateway. You can call this model from Netlify Functions without configuring API keys; the AI Gateway provides the connection to Google for you.
Example usage in a Function:
import { GoogleGenAI } from '@google/genai';export default async () => {const ai = new GoogleGenAI({});const response = await ai.models.generateContent({model: 'gemini-3.1-flash-lite-preview',contents: 'How can AI improve my coding?'});return Response.json(response);};This model works across any function type and is compatible with other Netlify primitives such as caching and rate limiting, giving you control over request behavior across your site.
Learn more in the AI Gateway documentation.
-
OpenAI’s GPT-5.3 Instant model is now available through Netlify’s AI Gateway with zero configuration required.
Use the OpenAI SDK directly in your Netlify Functions without managing API keys or authentication. The AI Gateway handles everything automatically. Here’s an example using the GPT-5.3 Instant model:
import OpenAI from 'openai';export default async () => {const openai = new OpenAI();const response = await openai.responses.create({model: 'gpt-5.3-chat-latest',input: 'How does AI work?'});return Response.json(response);};Note: The model API name is
gpt-5.3-chat-latest.GPT-5.3 Instant is available for all Function types. You get automatic access to Netlify’s caching, rate limiting, and authentication infrastructure.
Learn more in the AI Gateway documentation.
-
Google’s Gemini 3.1 Flash Image Preview, also known as Nano Banana 2, is now available through AI Gateway. You can call this image generation model from Netlify Functions without configuring API keys; the AI Gateway provides the connection to Google for you.
Example usage in a Function:
import { GoogleGenAI } from '@google/genai';export default async (request: Request) => {const url = new URL(request.url);const prompt = url.searchParams.get('prompt') || 'two happy bananas';const ai = new GoogleGenAI({});try {const response = await ai.models.generateContent({model: 'gemini-3.1-flash-image-preview',contents: prompt,config: {imageConfig: {aspectRatio: '16:9',imageSize: '1K'}}});let imagePart = null;for (const part of response.candidates[0].content.parts) {if (part.inlineData) {imagePart = part.inlineData;break;}}const bytes = Buffer.from(imagePart.data, 'base64');const mimeType = imagePart.mimeType || 'image/png';return new Response(bytes, {status: 200,headers: {'Content-Type': mimeType,'Cache-Control': 'no-store'}});} catch (err) {return new Response(JSON.stringify({ error: String(err), prompt }), {status: 500,headers: { 'Content-Type': 'application/json' }});}};This model works across any function type and is compatible with other Netlify primitives such as caching and rate limiting, giving you control over request behavior across your site.
Learn more in the AI Gateway documentation.
-
OpenAI’s GPT-5.3-Codex model is now available through Netlify’s AI Gateway with zero configuration required.
Use the OpenAI SDK directly in your Netlify Functions without managing API keys or authentication. The AI Gateway handles everything automatically. Here’s an example using the GPT-5.3-Codex model:
import OpenAI from 'openai';export default async () => {const openai = new OpenAI();const response = await openai.responses.create({model: 'gpt-5.3-codex',input: 'How can AI improve my coding?'});return Response.json(response);};GPT-5.3-Codex is available for all Function types. You get automatic access to Netlify’s caching, rate limiting, and authentication infrastructure.
Learn more in the AI Gateway documentation.
-
Google’s Gemini 3.1 Pro Preview model is now available through Netlify’s AI Gateway with zero configuration required.
Use the Google GenAI SDK directly in your Netlify Functions without managing API keys or authentication. The AI Gateway handles everything automatically. Here’s an example using the Gemini 3.1 Pro Preview model:
import { GoogleGenAI } from '@google/genai';export default async () => {const ai = new GoogleGenAI({});const response = await ai.models.generateContent({model: 'gemini-3.1-pro-preview',contents: 'How can AI improve my workflow?'});return Response.json(response);};Gemini 3.1 Pro Preview is available for all Function types. You get automatic access to Netlify’s caching, rate limiting, and authentication infrastructure.
Learn more in the AI Gateway documentation.
-
Anthropic’s Claude Sonnet 4.6 model is now available through Netlify’s AI Gateway and Agent Runners with zero configuration required.
Use the Anthropic SDK directly in your Netlify Functions without managing API keys or authentication. The AI Gateway handles everything automatically. Here’s an example using the Claude Sonnet 4.6 model:
import Anthropic from '@anthropic-ai/sdk';export default async () => {const anthropic = new Anthropic();const response = await anthropic.messages.create({model: 'claude-sonnet-4-6',max_tokens: 4096,messages: [{role: 'user',content: 'How can AI improve my coding?'}]});return Response.json(response);};Claude Sonnet 4.6 is available for all Function types and Agent Runners. You get automatic access to Netlify’s caching, rate limiting, and authentication infrastructure.
Learn more in the AI Gateway documentation and Agent Runners documentation.
-
Anthropic’s Claude Opus 4.6 model is now available through Netlify’s AI Gateway and Agent Runners with zero configuration required.
Use the Anthropic SDK directly in your Netlify Functions without managing API keys or authentication. The AI Gateway handles everything automatically. Here’s an example using the Claude Opus 4.6 model:
import Anthropic from '@anthropic-ai/sdk';export default async () => {const anthropic = new Anthropic();const response = await anthropic.messages.create({model: 'claude-opus-4-6',max_tokens: 4096,messages: [{role: 'user',content: 'How can AI improve my coding?'}]});return new Response(JSON.stringify(response), {headers: { 'Content-Type': 'application/json' }});};Claude Opus 4.6 is available for all Function types and Agent Runners. You get automatic access to Netlify’s caching, rate limiting, and authentication infrastructure.
Learn more in the AI Gateway documentation and Agent Runners documentation.
-
OpenAI’s GPT-5.2-Codex model is now available through Netlify’s AI Gateway and Agent Runners with zero configuration required.
Use the OpenAI SDK directly in your Netlify Functions without managing API keys or authentication. The AI Gateway handles everything automatically. Here’s an example using the GPT-5.2-Codex model:
import OpenAI from 'openai';export default async () => {const openai = new OpenAI();const response = await openai.responses.create({model: 'gpt-5.2-codex',input: 'How does AI work?'});return new Response(JSON.stringify(response), {headers: { 'Content-Type': 'application/json' }});};GPT-5.2-Codex is available across Background Functions, Scheduled Functions, and Agent Runners. You get automatic access to Netlify’s caching, rate limiting, and authentication infrastructure.
Learn more in the AI Gateway documentation and Agent Runners documentation.