functions
Browse all articles, tutorials, and guides about functions
Posts
One Key for Claude, GPT, and Gemini: the Gateway Pattern
Using three model providers usually means three API keys, three SDKs, and three billing relationships sprayed across your code. An AI gateway collapses that to one credential and one OpenAI-compatible endpoint. I proved it on a Neon Function: the same call answered by GPT, Claude, and Gemini.
Presigned-URL Uploads From a Serverless Function
Streaming user uploads through your API means the bytes cross your server twice, and serverless functions have request-size limits that make it worse. Presigned URLs let the browser upload straight to object storage while your function just hands out permission. Here it is on a Neon Function, tested end to end.
A Postgres-Backed MCP Server in ~20 Lines
Most of what an MCP server does is run database queries on behalf of an AI agent. So I put one right next to the database. Here is a Postgres-backed MCP server built on Neon Functions, deployed onto a database branch, with the code, a live client test, and the repo.
Preview Environments That Include the Backend, Not Just the Frontend
Every PR gets a frontend preview URL. The backend is almost always one shared staging database, so previews quietly lie to you. On Neon a branch is the database, its data, and the functions together, so each PR can get a real isolated backend. Here is the workflow, tested end to end.
Realtime Without a WebSocket Service
Live counters, presence, notifications: the reflex is to add a websocket service to run and pay for. But if your data already lives in Postgres, it has a pub/sub built in. Here is realtime fan-out with Postgres LISTEN/NOTIFY and SSE on a Neon Function, tested with two live subscribers.
Compute That Lives on Your Database Branch
Neon Functions run your code in the same region as your Postgres, on a per-branch URL. To see why that matters I deployed a small API and timed a query from inside the function versus from a machine across the Atlantic: 1.2 ms against 135 ms. Here is how it works, with the real numbers and the repo.
Streaming an AI Agent Without a Function Timeout
Long agent loops and long token streams run into the same wall: a serverless function that hits its execution cap and cuts the connection. Neon Functions hold long-lived streaming connections by default. I deployed two endpoints to prove it: one streamed for 90 seconds, the other streamed an agent token by token starting at 466 ms.
How to Convert a List to a String in Terraform
Learn different methods for converting lists to strings in Terraform using join(), jsonencode(), and format() functions for various use cases.
How to Concatenate Lists in Terraform Using concat()
Learn how to combine multiple lists in Terraform using the concat() function, plus advanced patterns for merging and manipulating list data.