Files
CatoandClaude Opus 5 a6906851d5 refactor(content): one markdown pipeline — bip-kit typed blocks replace MDX and two GitHub content repos (#183)
The blog and the Knowledge Center each fetched their markdown from a
SEPARATE GitHub repository at request time (g-but/botsmann-blog-content,
g-but/botsmann-knowledge-content) and rendered it through next-mdx-remote
with a hand-rolled component map per surface. Two maps for one markdown
vocabulary, already drifted: the blog slugged headings with rehype-slug, the
guides with a different inline regex; the guides highlighted code, the blog
did not; each had its own Callout. The content itself lived where nobody
reviewed it, behind a GitHub handle rename that now answers only via a 301.

Both surfaces now read content/*.md from this repo and render through
bip-kit's typed-block parser and reference renderer:

- content/blog/*.md (5 posts) and content/knowledge/**/*.md (10 guides) are
  vendered verbatim from the two content repos — word-level parity verified
  across all 15 files, zero words lost. Post images moved to public/blog/.
- The three app/blog/<slug>/page.mdx files came along as drafts. They were
  never routes: `page.mdx` only serves as a page when pageExtensions includes
  mdx, and this app never configured that, so all three were dead files. They
  are committed with `published: false` rather than deleted.
- lib/longform/ is the one pipeline both routes call: a fence-aware
  normalizer (`# ` → `## `, `*`/`+` bullets → `-`, nested items flattened —
  the guides carry 74 indented items and ~130 shell-comment `#` lines inside
  fences that a naive normalizer would have corrupted), then parse → blocks +
  TOC + reading time.
- setHighlighterLoader(() => import('shiki')) is registered at module scope.
  This app builds `output: standalone`, where bip-kit's zero-config shiki
  import is invisible to Next's file tracer — without the explicit literal,
  production ships unhighlighted while dev looks right.
- The TOC is derived from the same parse that renders the page, so a TOC
  anchor can no longer point at a heading id built by a different slug rule.
  types/knowledge.ts loses TableOfContentsItem accordingly.

Retired: next-mdx-remote, remark-gfm, rehype-slug, rehype-autolink-headings,
gray-matter (deps), components/blog/{Server,Client}MDXContent + MDXComponents,
components/knowledge/{Callout,CodeBlock,TableOfContents}. next.config drops
the raw.githubusercontent image pattern and the GitHub hosts from CSP
connect-src, and points frame-src at the privacy video players bip-kit uses.

Article typography now flows from the token SSOT: lib/longform/longform.css
maps globals.css onto bip-kit's --bp-* contract, replacing ~40 hardcoded
Tailwind greys. The mapping covers every --bp-* colour and pins the article
light, because Botsmann has no dark theme anywhere (zero `dark:` utilities,
no theme provider, light-only chrome) — letting bip-kit's dark defaults
through would put a dark article inside a white page. When the site grows a
dark tier, this file follows it by changing values in globals.css only.

tests/__tests__/lib/longform-content.test.ts walks every content file through
the real pipeline: committed content is bip-kit's trust boundary and a
malformed chart/stats fence throws at parse time, which without a test would
surface as a 500 on the live page.


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 14:24:40 +00:00

7.7 KiB
Raw Permalink Blame History

title, description, difficulty, readTime, author, publishedAt, tags, prerequisites, category, published
title description difficulty readTime author publishedAt tags prerequisites category published
AI Infrastructure Cost Estimation Guide Calculate your AI costs accurately - token pricing, compute costs, and hidden expenses explained Intermediate 15 min Botsmann Team 2026-01-12
costs
pricing
budgeting
tokens
infrastructure
Basic understanding of AI APIs
infrastructure true

AI Infrastructure Cost Estimation

Understanding the true cost of AI infrastructure helps you budget accurately and avoid surprises. This guide breaks down all cost components.

Understanding Token Pricing

What is a Token?

Tokens are the units AI models use to process text. Roughly:

  • 1 token ≈ 4 characters in English
  • 1 token ≈ 0.75 words
  • 1,000 tokens ≈ 750 words

Token Pricing Comparison (January 2026)

Model Input/1M Tokens Output/1M Tokens
GPT-4o $2.50 $10.00
GPT-4o mini $0.15 $0.60
Claude Opus 4 $15.00 $75.00
Claude Sonnet 4 $3.00 $15.00
Claude Haiku 3.5 $0.25 $1.25
Gemini 2.0 Pro $1.25 $5.00
Gemini 2.0 Flash $0.075 $0.30
Llama 3.1 (self-hosted) ~$0.10* ~$0.10*

*Self-hosted costs are compute-based, not per-token


Cost Scenarios

Scenario 1: Customer Support Chatbot

Usage: 10,000 conversations/month, avg 8 messages each

Component Tokens Calculation
User messages 4M input 10K × 8 × 50 tokens
Bot responses 2.4M output 10K × 8 × 30 tokens
System prompts 1M input 10K × 100 tokens

Monthly Costs:

Model Cost
GPT-4o $36.50
GPT-4o mini $2.19
Claude Sonnet 4 $51.00
Claude Haiku $4.25
Gemini Flash $1.10

Recommendation: Start with Claude Haiku or Gemini Flash, upgrade model for complex queries only.


Scenario 2: Code Assistant

Usage: 50 developers, 100 queries/day each

Component Tokens Calculation
Code context 100M input 50 × 100 × 20K tokens
Queries 2.5M input 50 × 100 × 500 tokens
Responses 25M output 50 × 100 × 5K tokens

Monthly Costs:

Model Cost
GPT-4o $506
Claude Sonnet 4 $682
Claude Haiku $56

Recommendation: Claude Sonnet for quality (coding is its strength), Haiku for cost optimization.


Scenario 3: Document Analysis Platform

Usage: 1,000 documents/month, avg 50 pages each

Component Tokens Calculation
Document input 375M input 1K × 50 × 7,500 tokens
Analysis output 10M output 1K × 10K tokens

Monthly Costs:

Model Cost
GPT-4o $1,037
Claude Sonnet 4 $1,275
Gemini 1.5 Pro $519
Self-hosted Llama ~$200 (compute)

Recommendation: Gemini for massive context, or self-host Llama for recurring large volumes.


Infrastructure Costs

Hosting Costs

Scale Vercel Railway AWS Self-Hosted
Hobby (1K users) $0 $5 $10 $5
Startup (10K users) $20 $25 $50 $20
Growth (100K users) $150 $100 $300 $60
Scale (1M users) $1,000+ $500 $2,000 $300

Database Costs

Service Free Tier Paid
Supabase 500MB $25/mo (8GB)
PlanetScale 5GB $29/mo
Neon 0.5GB $19/mo
Self-hosted Postgres - $5-20/mo VPS

Vector Database Costs (for RAG)

Service Free Tier Paid
Pinecone 1 index $70/mo
Weaviate Cloud Limited $25/mo
Qdrant Cloud 1GB $25/mo
Self-hosted - $10-50/mo

Hidden Costs

Often Overlooked

  1. Embeddings - $0.02/1M tokens for text-embedding-3-small
  2. Image Processing - GPT-4o vision costs ~$0.01/image
  3. Caching Infrastructure - Redis/Upstash $0-25/mo
  4. Monitoring - Datadog, LogRocket $0-100/mo
  5. Error Rates - 1-5% of requests may fail/retry
  6. Development - Testing uses tokens too!

Cost Optimization Strategies

Strategy Savings Effort
Use smaller models for simple tasks 50-90% Low
Implement caching 30-70% Medium
Optimize prompts (fewer tokens) 20-40% Low
Batch requests 10-30% Medium
Self-host for predictable loads 50-80% High

Budget Templates

Startup MVP (~$100/month)

Component Cost
AI API (GPT-4o mini) $50
Vercel Pro $20
Supabase $0-25
Domain $1
Total ~$100

Growing Product (~$500/month)

Component Cost
AI API (mixed models) $200
Hosting (Railway/Vercel) $100
Database (managed) $50
Vector DB $50
Monitoring $50
Total ~$500

Scale Product (~$2,000/month)

Component Cost
AI API $800
AWS/GCP $500
Databases $200
Caching $100
Monitoring $200
Security/compliance $200
Total ~$2,000

Cost Calculator Formula

Monthly Cost =
  (Input Tokens × Input Price/1M) +
  (Output Tokens × Output Price/1M) +
  Hosting +
  Database +
  Other Services +
  15% Buffer

Example:

  • 5M input tokens @ $2.50/1M = $12.50
  • 2M output tokens @ $10/1M = $20.00
  • Vercel Pro = $20.00
  • Supabase = $25.00
  • Buffer (15%) = $11.63

Total: ~$89/month


Recommendations by Budget

Monthly Budget Strategy
$0-50 Free tiers everywhere, GPT-4o mini
$50-200 Vercel Pro, mix of models by complexity
$200-500 Consider self-hosting DB, optimize caching
$500-2000 Self-host where it makes sense, premium models
$2000+ Dedicated infrastructure, enterprise APIs

Tracking Your Costs

API Cost Dashboards

  • OpenAI: platform.openai.com/usage
  • Anthropic: console.anthropic.com/settings/billing
  • Google: console.cloud.google.com/billing

Tools for Monitoring

  • Helicone - AI API proxy with analytics
  • LangSmith - LangChain's observability platform
  • Portkey - AI gateway with cost tracking

Set up alerts at 80% of budget to avoid surprises!