---
title: "Mozilla Llamafile in Supabase Edge Functions"
description: "Supabase Edge Functions can now use Mozilla Llamafile, alongside Ollama, as the inference server via an OpenAI-API-compatible mode."
url: "https://swe.quest/articles/mozilla-llamafile-in-supabase-edge-functions-f67e9f7e5ebbcb62"
canonical: "https://supabase.com/blog/mozilla-llamafile-in-supabase-edge-functions"
source: "Supabase"
published: "2024-08-21"
difficulty: "medium"
kind: "How-to"
reading_minutes: 4
tags: ["serverless","inference","llms","typescript"]
---

# Mozilla Llamafile in Supabase Edge Functions

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2024-08-21, 4 min read, How-to. Original: [https://supabase.com/blog/mozilla-llamafile-in-supabase-edge-functions](https://supabase.com/blog/mozilla-llamafile-in-supabase-edge-functions)

## Summary

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.

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)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)

## Prerequisites

- Supabase CLI ([easy posts on Developer tools](https://swe.quest/tags/developer-tools.md?difficulty=easy))
- Deno basics
- OpenAI chat completions API

## Keywords

Supabase Edge Functions, Mozilla Llamafile, Ollama, OpenAI Deno SDK, Deno, Fly.io

## Related posts

- [AI Inference now available in Supabase Edge Functions](https://swe.quest/articles/ai-inference-now-available-in-supabase-edge-functions-9d09d3bcda534938.md): Supabase · 2024-04-16 · Medium · 5 min read · Serverless, Inference & serving, Vector search, LLMs
  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.
- [Edge Functions are now available in Supabase](https://swe.quest/articles/edge-functions-are-now-available-in-supabase-3c06235615e01037.md): Supabase · 2022-03-31 · Easy · 7 min read · Serverless, CDN & edge, TypeScript, System design
  Supabase Edge Functions run TypeScript globally on the Deno runtime via Deno Deploy across 30+ data centers.
- [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.
- [Building ChatGPT Plugins with Supabase Edge Runtime](https://swe.quest/articles/building-chatgpt-plugins-with-supabase-edge-runtime-b0cdffa93584d3d5.md): Supabase · 2023-05-15 · Medium · 6 min read · AI agents, Serverless, TypeScript, API design
  A TypeScript template for ChatGPT Plugins runs on Supabase Edge Runtime (Deno).
- [Supabase Edge Runtime: Self-hosted Deno Functions](https://swe.quest/articles/supabase-edge-runtime-self-hosted-deno-functions-55b12d1d5db96506.md): Supabase · 2023-04-11 · Medium · 7 min read · Serverless, Runtimes & VMs, JavaScript, Rust, Open source
  Supabase Edge Runtime is an MIT-licensed, Rust-based web server built on deno\_core that self-hosts Deno Edge Functions (TypeScript, JavaScript, WASM) without code changes.

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)
