Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Supabase 5 min read Announcement mediumAdept

AI Inference now available in Supabase Edge Functions

Supabase Edge Functions gain a built-in Supabase.ai.Session API for running AI inference in a few lines of code, starting with gte-small embeddings for storage in pgvector and experimental, invite-only Llama and Mistral LLMs with streaming responses. Embeddings run on a native Edge Runtime extension that calls ONNX Runtime through the Rust Ort wrapper, replacing the slow WASM boot of Transformers.js. A typical embedding request finishes in under 1s even from a cold start and uses 100-200ms of CPU, and Supabase claims this is about 10x cheaper than OpenAI's embedding API with comparable MTEB scores. LLM requests are routed to GPU-accelerated Ollama servers, and database webhooks can trigger embedding generation automatically when rows are inserted.

Related posts

  • Mozilla Llamafile in Supabase Edge Functions

    Supabase mediumAdept

    Supabase Edge Functions can now use Mozilla Llamafile, alongside Ollama, as the inference server via an OpenAI-API-compatible mode. Setup takes one of two paths. You can set AI_INFERENCE_API_HOST and call Supabase.ai.Session with mode 'openaicompatible'. Or you can point the OpenAI Deno SDK at the Llamafile server through OPENAI_BASE_URL and stream responses back as server-sent events. With the SDK, the model parameter is ignored because the model is whichever Llamafile is running. The walkthrough covers local serving with the Supabase CLI, deploying a containerized Llamafile to a host like Fly.io, and setting secrets to deploy the functions.

  • Hugging Face is now supported in Supabase

    Supabase mediumAdept

    Supabase adds first-class Hugging Face support for generating embeddings stored in pgvector, as an open-source, self-hostable alternative to OpenAI's text-embedding-ada-002. The Python vecs client gains "adapters" that chunk text and embed it automatically on upsert and query. Edge Functions can run Transformers.js inference in Deno, and small models can even run in the browser and query pgvector through PostgREST and RLS. Supabase recommends lower-dimension models such as gte-small for cheaper storage and faster retrieval, and notes current limits: 2-6s cold starts from model downloads, and no turnkey audio/image decoding in Deno.

  • database.build v2: Bring-your-own-LLM

    Supabase mediumAdept

    database.build, Supabase's in-browser Postgres sandbox built on PGlite, now lets users bring any OpenAI-compatible LLM, with no login and no rate limits. Requests go straight from the browser to the provider. This works because most LLM APIs send CORS headers, and a service worker intercepts the Vercel AI SDK's /api/chat route, reading its BYO-LLM config from IndexedDB. Models need reliable tool calling, SQL knowledge and Chart.js knowledge, so gpt-4o is recommended; local Ollama models still struggle with tool calls, and Ollama buffers tool-call streams. The release also adds one-click deploys to Supabase by piping server-side pg_dump over Live Share into pg_restore, and replaces the tar.gz export with a WASM pg_dump. Serverless PGlite was shelved because of its memory use and single-connection limit in multi-tenant setups and unreliable s3fs storage.

  • Automatic Embeddings in Postgres

    Supabase mediumAdept

    Supabase moves embedding generation coordination into Postgres. Insert and update triggers enqueue jobs in pgmq, pg_cron batches them, and pg_net calls an Edge Function that hits an embedding API, then writes results into a pgvector column. The design avoids drift between content and vectors and keeps slow inference off the write path. Embeddings are briefly null after a write until the async job completes. A generated-column approach is rejected because it blocks writes unless the model is local and fast.

  • Building ChatGPT Apps with Supabase Edge Functions and mcp-use

    Supabase mediumAdept

    ChatGPT apps built on OpenAI's Apps SDK consist of an MCP server backend and an iframe-rendered web component, and mcp-use lets that MCP server run on Supabase Edge Functions by using Hono instead of the Express-based official SDK. The walkthrough builds a database explorer exposing list-tables, show-table, execute-SQL and Supabase-status tools, each returning React widgets. It distinguishes display-only widgets, which are auto-registered as tools and fetch data client-side, from data-returning widgets, where the server sends separate props to the UI and output to the LLM. It closes with deployment via an mcp-use script and connecting the endpoint in ChatGPT developer mode.

The quest for software engineering knowledge.

Look:
Layout: