Bluemesh
Language: EnglishEN
Menu

Home / Selected work

A production generative AI platform with six model providers and more than 40% fewer prompt tokens

Bluemesh's lead architect joined a pre-seed startup as its senior AI architect and built its generative AI platform end to end, from discovery to paying users. The engineering focus was cost: fewer tokens, fewer model calls, and freedom to change providers.

At a glance

Service
AI Solutions Architecture
Stack
Python, FastAPI, LangGraph, React
When
2026
Who
Bluemesh's lead architect, as senior AI architect for a pre-seed startup. Startup not named.

Results

fewer prompt tokens
40%+
extraction calls, schema-validated
22 → 1
automated tests, run in CI as the release gate
800+
Talk to Bluemesh

The story

The situation

A pre-seed startup needed its generative AI platform built end to end, from discovery to paying users.

What was really holding it back

Cost and lock-in: the model tokens each request uses, the number of model calls, and the freedom to change providers without rewriting the product.

What was decided, and why

  • Six providers behind one interface. A handler factory over OpenAI, Azure OpenAI, Anthropic, DeepSeek, Groq and Gemini. Prompts, model settings, response schemas and scoring rules are stored as data, so switching vendors is a configuration change.
  • Only the text that changes goes to the model. A pass-through data design keeps factual fields in the application and sends only the text to rewrite. Prompt tokens fell by more than 40%.
  • One call instead of twenty-two. A 22-call extraction became one schema-validated call.
  • The right model for each task. Small and mid-tier models for planning and validation, quality models for generation, chosen by configuration.
  • An agent workflow with a safe path. A LangGraph planner, parallel section optimizers, a merger, and scoring on a deterministic path with no model cost, plus a model-based safety check. Released behind a feature flag, with the previous version as the fallback.
  • Built for load. Asynchronous jobs (202 with a job ID), back-pressure (503 with Retry-After), streaming with server-sent events, and correlation IDs to trace any output across services.
  • Caching and cost tracking. A three-layer Redis cache keyed by content hash, and model token and cost accounting on every request.

How it was tested

More than 800 automated tests, including an extraction regression suite and scoring contract tests, run in CI as the gate for any prompt or model change. Providers handle structured output differently, so the platform validates every output against its schema instead of trusting the provider.

The result

The platform is live with paying subscribers.

How the parts fit

The parts used in this project, in the order a request moves through them.

  1. Web appReact and TypeScript
  2. API gatewayFastAPI, async jobs, streaming
  3. LLM servicesix providers, one interface
  4. LangGraph workflowplan, optimize, merge, score
  5. Redis cachethree layers
  6. CMS and PostgreSQLprompts and settings as data

Technology used in this project

  • Python
  • FastAPI
  • asyncio
  • Pydantic v2
  • LangGraph
  • Redis
  • PostgreSQL
  • React
  • TypeScript
  • Azure OpenAI
  • OpenAI
  • Anthropic
  • DeepSeek
  • Groq
  • Gemini
  • Sentence-transformer embeddings
  • ChromaDB
  • Server-sent events
  • OAuth sign-in (Google, Microsoft)
  • Signed-webhook payments

How Bluemesh builds it today

A reference architecture for a new project, based on current Azure and AWS guidance. It describes what Bluemesh would build now, not what was built in the project above.

For a new platform

  • A model gateway with token limits and cost per task from day one.
  • Prompts, model choices and schemas versioned as data, with an evaluation gate before any change ships.
  • A deterministic path wherever code can check the answer, and models only where judgment is needed.

Operations

  • Tracing across services with OpenTelemetry, dashboards on cost and latency per task, and alerts when a provider slows down or fails.

Questions

How do you reduce LLM costs in production?

Send the model only the text it must change, cache results, merge repeated calls, and route each task to the smallest model that passes its tests. Track tokens and cost on every request, so the savings are measured.

How do you avoid lock-in to one model provider?

Put providers behind one interface, store prompts and model choices as configuration, and validate every output against a schema in your own code.

How do you test an LLM feature before release?

With regression suites that run in CI: deterministic checks wherever the answer is structured, and a gate that blocks any prompt or model change that makes results worse.