{
  "id": 17668757,
  "title": "I built an open-source ad server for AI chat apps that keeps the chat on your server",
  "url": "https://urgent.news/2026/11/01/i-built-an-open-source-ad-server-for-ai-chat-apps-that-keeps-the-chat",
  "topic": "ai",
  "section": "AI",
  "published": "2026-11-01T20:02:12.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/pritom14/i-built-an-open-source-ad-server-for-ai-chat-apps-that-keeps-the-chat-on-your-server-15lh"
  },
  "original_language": "en",
  "account": "You have likely noticed that running a free AI app incurs costs. These expenses arise from ads that most users won't pay for, making ads a practical solution. When building your own AI application and seeking ads, options are limited. You can join an existing AI ad network, but this comes with certain drawbacks. The network requires access to your conversation to match ads, and it typically takes a share of the revenue generated. Alternatively, you could build your own ad system, but this involves addressing tasks like matching, budgeting, click tracking, fraud prevention, and reporting - all of which require considerable time and effort compared to your primary product. Conversely, you could hardcode a sponsor banner that displays the same ad to everyone, irrespective of their queries, but this approach proves ineffective. As such, I developed Aside, an open-source ad server designed specifically for AI chat applications, enabling you to host the server on your own infrastructure, adjacent to your application. The conversation data remains within your system. The demonstration features a fictitious free cooking assistant called Rasoi AI, which you can experiment with at aside-ads.onrender.com. A user might ask, \"Paneer butter masala for 4 people?\" and receive the recipe, accompanied by a card labeled 'Sponsored: get the ingredients delivered in 10 minutes.' In another instance, the query \"My kadhai keeps sticking, how do I fix it?\" would be accompanied by an ad for cast-iron cookware. No ad appears for a question like \"Who invented the pressure cooker?\" because there is no relevant ad available. The ad is displayed beside the answer but never integrated into the model's response. The matching process occurs locally. Aside embeds the user's most recent message into a small local model (bge-small-en-v1.5 via fastembed, running on CPU) and compares it to each campaign's targeting text. No third-party involvement occurs, ensuring relevance. There is a relevance threshold (default set at 0.65). If the relevance score falls below this threshold, Aside returns no ad, and the response explains why (mentioned as 'below_relevance_threshold'), facilitating easy tuning. Sensitive conversations are protected by a guard that checks for topics such as self-harm, medical emergencies, grief, and financial distress, blocking ads by default in these cases. The demo also safeguards the next few turns from ads following a sensitive message. An auction determines the winning ad. Campaigns bid per click or per thousand views. The bid multiplied by the relevance score ranks the campaigns, and the highest-ranked campaign pays a second price. Budgets are managed in the database, with daily and total budgets, as well as pacing across the day and frequency caps per user. The budget is reserved upon ad selection, not upon display, preventing overspending due to sudden bursts. Impression and click links are HMAC-signed and expire, ensuring the tracking cannot be tampered with. Clicks and conversions are deduplicated, meaning that a retried conversion postback is counted only once. No chat text is stored within the system. Only ad IDs, hashed user IDs, and timestamps are kept. There is a test that would fail if any conversation text were to be stored. To utilize Aside, install it via pip install aside-ads, and then run aside seed-demo --scenario cooking to seed the demo with sample sponsors in Indian Rupees (INR). You can start the ad server and dashboard by running aside serve, which will launch the server and dashboard on port :8000. From your application (Python or TypeScript), import AsideClient from aside_ads_client. The client is initialized with the server's URL and an API key. You can then retrieve sponsored ads by calling aside.get_sponsored() with your user's message and user ID, along with specifying the placement. If an ad is returned, you can display it beside the answer using the provided functions.",
  "summary": "Every message in a free AI app costs the person running it money. Most users will never pay for a subscription, so ads are the obvious way to cover the bill. ChatGPT started showing ads on its free tier this year. If you run your own AI app and want ads today, the options are not great: Join an AI ad network. It works, but the network usually needs to see the user's conversation to pick an ad,…",
  "key_points": [
    "Aside is open-source ad server for AI chat apps",
    "Conversation data stays within user's infrastructure",
    "No chat text stored in system, only ad IDs and metadata"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}