Guides

Ollama with a cloud API: Open WebUI plus Tchavi, paid by M-Pesa

TchaviBy Gael — Tchavi founder

· 12 min read

Back to blog

Table of contents

Many developers install Ollama for the same reason: to run an AI model on their own machine, without a bank card and without paying in dollars. It works, and on a good machine it works well. Then comes the day the local model is too slow to answer a customer, the laptop does not have enough memory, or the PC is simply switched off.

The question I get at that point: can you plug Tchavi into Ollama? The short answer is no, and that is fine. Ollama only talks to your local models and to its own cloud. But you can make the two work side by side, in the same interface or in the same code, and that is what I measured here.

In short

  • Tchavi, an OpenAI-compatible AI API gateway you pay for with mobile money, does not plug into Ollama. Ollama serves the models on your machine and the ones on its own cloud service, nothing else.
  • You run them side by side. Open WebUI shows your Ollama models and Tchavi's in the same list, and the same code can call one, then the other.
  • On a Mac M4 Pro with 48 GB, Qwen 3.6 running locally got everything right, in 10 to 39 seconds. GPT-6 Luna through Tchavi gave the same correct answers in 3 to 4 seconds, for about KES 0.01 per request.
  • When Ollama does not answer, the code falls back to Tchavi: answer in 5.3 seconds, with nothing to change by hand.
  • On a laptop with 8 or 16 GB, these local models do not fit: Qwen 3.6 is 23 GB, Qwen 3.8 is 17 GB.
  • Tchavi is paid with M-Pesa and other mobile money, with no bank card (countries and operators).

Why Tchavi does not plug into Ollama

Ollama does two things: it downloads models and runs them on your machine, and it offers "cloud" models that run on its own servers, with an Ollama key. Its documentation has no setting to redirect requests to another API.

What Ollama has in common with Tchavi is the format: both answer like the OpenAI API. Ollama at http://localhost:11434/v1, Tchavi at https://tchavi.com/api/v1. Any tool that accepts two OpenAI-compatible addresses, or any code that can call two, can use both. Here are two ways to do it.

How your local models compare with Tchavi

Before choosing, I measured. Two shop tasks, in French, given to four models, once each. The test task was a French-language shop order from Benin, which is what I measured, so the amounts below are in francs (F):

  • Extraction: turn "Bonsoir, je veux 3 pagnes wax bleus et 2 sacs en raphia, livraison à Porto-Novo samedi. Je paie par MTN MoMo." (a WhatsApp order in French) into an order in JSON.
  • Calculation: apply a delivery grid (Cotonou 1,000 F, Abomey-Calavi 1,500 F, Porto-Novo 2,000 F; free from 25,000 F of purchases, except in Porto-Novo, where it is only halved) to a customer in Porto-Novo buying 3 wax cloths at 6,500 F and 2 bags at 4,000 F. The right answer is 28,500 F.
ModelWhereExtractionCalculationCost per request
Qwen 3.6 (23 GB)Ollamacorrect, 9.9 scorrect, 38.7 s0
Qwen 3.8 (17 GB)Ollamacorrect, 8.1 scorrect, 15.1 s0
GPT-6 LunaTchavicorrect, 4.3 scorrect, 3.2 s0.13 to 0.14 credit, about KES 0.01
Claude Sonnet 5.5Tchavicorrect, 3.8 scorrect, 2.9 s2.7 to 5.7 credits, about KES 0.21 to 0.43

Measured in October 2026 on a Mac M4 Pro with 48 GB of memory, Ollama 0.40.8, one run per model and task, local models already loaded in memory. Tchavi was called from a test instance at public prices. I measured with the French prompt and French messages. KES amounts are about 1 credit = KES 0.076, the rate at October 2026 (KES 1,000 buys about 13,200 credits).

This table says three things.

On a powerful machine, local models do the job. All four models got both tasks right. To sort messages or do a simple calculation, a good local model is enough.

But they take their time. Qwen 3.6 thinks at length before it answers: 2,431 tokens generated for the calculation, reasoning included, which took close to 39 seconds. Loading the model into memory adds 10 to 14 seconds to the first call. For a customer waiting on WhatsApp, that is long; GPT-6 Luna answers in 3 to 4 seconds.

And the machine matters most. These figures come from a high-end computer. Qwen 3.6 takes 23 GB and Qwen 3.8 takes 17 GB: on the 8 or 16 GB laptop most developers use, they do not load, and you have to go down to much smaller models, which I did not test here.

Option 1: Open WebUI, one interface for both

Open WebUI is a chat interface widely used with Ollama. It accepts several connections at once: one to Ollama, one to any OpenAI-compatible API. Your local models and Tchavi's then show up in the same list.

At launch. This is the method I tested: three environment variables, and Open WebUI starts with both connections.

export OLLAMA_BASE_URL=http://localhost:11434
export OPENAI_API_BASE_URL=https://tchavi.com/api/v1
export OPENAI_API_KEY=sk-tch-your-key
uvx --python 3.11 --from open-webui open-webui serve

uvx installs Open WebUI separately, with Python 3.11 (it needs 3.11 or 3.12), without touching your system Python. If you already have one of those versions, pip install open-webui then open-webui serve does the same thing; Open WebUI also comes as a Docker image, described in its documentation. On first launch it downloads a small model used for document search: allow a few minutes before the page responds, at http://localhost:8080.

Tested with Open WebUI 0.12.3: the list showed my 5 Ollama models (3 installed on the machine, 2 from Ollama's cloud) and Tchavi's models, more than 100, side by side. The same question ("In one sentence: what is the capital of Benin?") got the right answer from both sides: in 1.8 seconds and for 0.021 credit, about KES 0.002, with GPT-6 Luna; in 6.8 seconds, 3.3 of them loading, with Qwen 3.6.

Tchavi's list also contains its image, video and audio models: in the chat, pick a text model.

From the interface. If Open WebUI is already running, open Admin Settings → Connections, then, in the OpenAI section, add a connection:

  • URL: https://tchavi.com/api/v1
  • Key: your Tchavi key, which starts with sk-tch-

Leave the Ollama connection as it is. This is also where you change the key later: Open WebUI stores its configuration on first launch, and environment variables no longer replace it afterwards.

Give this key a spend limit from your dashboard: a chat interface shared with a team is exactly where a capped key avoids surprises.

Option 2: in your code, Ollama first, Tchavi as backup

The same OpenAI SDK talks to both. The code below asks the local model first, checks that its answer is usable, and switches to Tchavi if Ollama is off, too slow or gets the format wrong. This is the code I tested, with the French prompt; only Tchavi's address then pointed to my test instance. The instructions below are an English version of the same idea.

import OpenAI from 'openai';

// Ollama locally, Tchavi as backup. Both speak the OpenAI format.
const local = new OpenAI({
  baseURL: process.env.OLLAMA_URL ?? 'http://localhost:11434/v1',
  apiKey: 'ollama', // Ollama does not need one, but the SDK requires a value
  maxRetries: 0, // if Ollama does not answer, switch right away
});

// The model your machine runs. qwen3.6 is 23 GB and needs more memory than
// that; on an 8 or 16 GB laptop, pick a smaller model.
const LOCAL_MODEL = process.env.LOCAL_MODEL ?? 'qwen3.6';

const tchavi = new OpenAI({
  baseURL: 'https://tchavi.com/api/v1',
  apiKey: process.env.TCHAVI_API_KEY,
});

const INSTRUCTIONS =
  'You extract orders from the WhatsApp messages of a shop. Reply only with a JSON object with these keys: intent ("order", "complaint", "question" or "other"), items (list of {product, quantity}), city, day, payment.';

// An unusable answer counts as a failure: better to pay a fraction of a cent
// at Tchavi than to record a wrong order.
function parseOrder(text) {
  const d = JSON.parse(text);
  if (!['order', 'complaint', 'question', 'other'].includes(d.intent)) {
    throw new Error('unknown intent');
  }
  if (d.intent === 'order' && !d.items?.length) {
    throw new Error('order without items');
  }
  return d;
}

async function ask(client, model, message) {
  const response = await client.chat.completions.create(
    {
      model,
      messages: [
        { role: 'system', content: INSTRUCTIONS },
        { role: 'user', content: message },
      ],
      response_format: { type: 'json_object' },
    },
    { timeout: 30_000 },
  );
  return parseOrder(response.choices[0].message.content);
}

export async function extractOrder(message) {
  try {
    return { source: 'local', order: await ask(local, LOCAL_MODEL, message) };
  } catch {
    // Ollama off, too slow or unusable answer: Tchavi takes over.
    return { source: 'tchavi', order: await ask(tchavi, 'gpt-6-luna', message) };
  }
}

I ran this code in the two situations that matter:

SituationWho answeredTimeOrder extracted
Ollama onQwen 3.621.9 s3 wax cloths, 2 bags, Porto-Novo, MTN MoMo
Ollama unreachableGPT-6 Luna5.3 s3 wax cloths, 2 bags, Porto-Novo, MTN MoMo

Two details make the difference. maxRetries: 0: without it, the SDK retries a dead connection twice before giving up, and the switch took 9 seconds instead of 5.3. The parseOrder check: a local answer that is not valid JSON, or an order with no items, triggers the backup too, instead of landing in your database.

The 30-second timeout is a compromise. Qwen 3.6 took up to 39 seconds on the calculation: with a shorter timeout, those requests would go to Tchavi, which may be exactly what you want for a customer who is waiting.

What about coding agents?

Same principle for coding agents that accept several providers. In OpenCode, the provider block of opencode.json takes one entry per provider: its documentation shows the Ollama entry, and our OpenCode guide shows Tchavi's. Both can live in the same file. I did not test it here; for Claude Code, which accepts only one address, see Claude Code without a credit card.

What the Tchavi backup costs

The local model costs nothing beyond your machine and your electricity. The backup is paid per request, in credits topped up with mobile money. The conversion is about KES 1,000 for 13,200 credits at October 2026 rates (the live figure is on the top-up page).

ModelOne extraction as above1,000 messages a day, over a month (30,000 requests)
GPT-6 Luna0.13 credit, about KES 0.01about 3,900 credits, about KES 300
Claude Sonnet 5.52.7 credits, about KES 0.21about 82,000 credits, about KES 6,200

If Ollama answers most messages and Tchavi only takes the rest, you only pay for the rest. That is the whole point of the setup: local for volume, Tchavi when you need speed, when the machine cannot keep up, or when the task is beyond the local model. The account starts at 0 credits, there are no free signup credits, and your first paid top-up adds a bonus of 150 credits. The minimum top-up is KES 250, and credits never expire.

FAQ

Can you use Tchavi inside Ollama?

No. Ollama only serves the models installed on your machine and those of its own cloud service. But since Ollama and Tchavi both speak the OpenAI API format, an interface like Open WebUI or your own code can use both at the same time.

Can Open WebUI use Ollama and an external API at the same time?

Yes. Open WebUI accepts an Ollama connection and OpenAI-compatible connections side by side, in Admin Settings → Connections. With Tchavi added as an OpenAI-compatible connection (https://tchavi.com/api/v1), your local models and Tchavi's appear in the same list.

Which Ollama model should I pick on an 8 or 16 GB laptop?

A model much smaller than your machine's memory. The two models tested here are 23 GB and 17 GB and do not load on those laptops. Ollama's library has versions of a few gigabytes; I did not evaluate them in this article, so test them on your own messages before trusting them with customers.

Does my data stay on my machine?

With Ollama running locally, yes: the model runs at your end. When the code switches to Tchavi, the request is processed by the publisher of the model you chose and, depending on the model, by the host that runs it for them, each under its own privacy policy. For text, Tchavi logs the model, the tokens used and the cost, not the content of requests.

How much does the Tchavi backup cost?

On the task measured here, about KES 0.01 per request with GPT-6 Luna and about KES 0.21 to 0.43 with Claude Sonnet 5.5, at October 2026 rates. You only pay for requests that actually go through Tchavi, in credits topped up with mobile money from KES 250.

Do I need a bank card?

No. Ollama is free, and Tchavi is topped up with mobile money, with no card and no subscription. Credits you buy never expire.


To add the backup, create your account and top up KES 250 with mobile money, then generate a capped key for Open WebUI or for your code.

This article is part of the series "Building an AI product from Africa". Tchavi is an OpenAI-compatible AI API gateway: one key gives access to over 100 text, image, audio and video models, and you pay for it with mobile money, no bank card (countries and operators). In the series: paying for the OpenAI or Claude API with M-Pesa, Claude Code without a credit card and AI transcription for WhatsApp voice notes in Swahili. More guides, in French: the French blog. Follow us: LinkedIn and X.

Share

Your first API call, paid with mobile money

No bank card. Top up with mobile money in your local currency; your first top-up adds 150 bonus credits, and credits never expire.