---
title: "AI Inference now available in Supabase Edge Functions"
description: "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."
url: "https://swe.quest/articles/ai-inference-now-available-in-supabase-edge-functions-9d09d3bcda534938"
canonical: "https://supabase.com/blog/ai-inference-now-available-in-supabase-edge-functions"
source: "Supabase"
published: "2024-04-16"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 5
tags: ["serverless","inference","vector-search","llms"]
---

# AI Inference now available in Supabase Edge Functions

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2024-04-16, 5 min read, Announcement. Original: [https://supabase.com/blog/ai-inference-now-available-in-supabase-edge-functions](https://supabase.com/blog/ai-inference-now-available-in-supabase-edge-functions)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Vector search](https://swe.quest/tags/vector-search.md) (Data & databases)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)

## Prerequisites

- text embeddings ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))
- serverless functions ([easy posts on Serverless](https://swe.quest/tags/serverless.md?difficulty=easy))

## Keywords

Supabase Edge Functions, ONNX Runtime, Ort, Ollama, pgvector, gte-small, Transformers.js, Deno

## Related posts

- [Mozilla Llamafile in Supabase Edge Functions](https://swe.quest/articles/mozilla-llamafile-in-supabase-edge-functions-f67e9f7e5ebbcb62.md): Supabase · 2024-08-21 · Medium · 4 min read · Serverless, Inference & serving, LLMs, TypeScript
  Supabase Edge Functions can now use Mozilla Llamafile, alongside Ollama, as the inference server via an OpenAI-API-compatible mode.
- [Hugging Face is now supported in Supabase](https://swe.quest/articles/hugging-face-is-now-supported-in-supabase-b922ce506c4fa31d.md): Supabase · 2023-08-07 · Medium · 7 min read · Vector search, PostgreSQL, Serverless, Python, JavaScript
  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.
- [database.build v2: Bring-your-own-LLM](https://swe.quest/articles/database-build-v2-bring-your-own-llm-b2a3b83eee7ef5a0.md): Supabase · 2024-12-06 · Medium · 11 min read · PostgreSQL, LLMs, Browsers, WebAssembly
  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.
- [Automatic Embeddings in Postgres](https://swe.quest/articles/automatic-embeddings-in-postgres-41612b12257af4ee.md): Supabase · 2025-04-01 · Medium · 6 min read · PostgreSQL, Vector search, RAG & retrieval, Queues & messaging
  Supabase moves embedding generation coordination into Postgres.
- [Building ChatGPT Apps with Supabase Edge Functions and mcp-use](https://swe.quest/articles/building-chatgpt-apps-with-supabase-edge-functions-and-mcp-use-0df00526c3d8cd4e.md): Supabase · 2025-12-17 · Medium · 9 min read · AI agents, Serverless, TypeScript, React
  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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
