59API

← Retour aux guides

Cut AI Costs with Shorter, Smarter Prompts

Tarifs · EN · 2026-07-09

Fine-Tuning Prompts for Cheaper, Shorter AI Outputs

AI API bills usually grow for one simple reason: too many tokens going in, too many tokens coming out. The good news is that you can often reduce cost without changing models, rewriting your app, or lowering quality. By tightening your prompts, setting clearer output limits, and removing unnecessary context, you can make Claude and GPT models respond faster, shorter, and more predictably.

This tutorial walks through practical steps developers can apply immediately. The examples work with Claude, GPT models, Claude Code, Codex, and OpenAI-compatible SDKs. If you use a relay such as 59API, whose base URL is https://api.59api.com, these techniques combine especially well with already low pay-as-you-go pricing across Claude Opus, Sonnet, Haiku, Fable, and GPT models.

Step 1: Measure Your Current Token Waste

Before editing prompts, identify where the waste is. Look at three things: your system prompt, the user prompt, and the model output. In many apps, the output is the biggest cost driver because developers ask for open-ended answers such as “explain in detail” or “write a comprehensive response.”

Run five to ten real requests from your application and record the approximate input and output tokens. If your responses are 800 words but users only need 150, you have an easy optimization target. Also check whether your app repeatedly sends the same long instructions, large schemas, or irrelevant conversation history on every request.

Step 2: Replace Vague Requests with Output Contracts

Models are more concise when they know the exact shape of the answer. Instead of saying “summarize this support ticket,” specify the format and maximum length.

Weak prompt: “Summarize this ticket and suggest a solution.”

Better prompt: “Return a 3-bullet summary and one recommended next action. Each bullet must be under 18 words. Do not include greetings or explanations.”

This works because you are not merely asking the model to be short; you are defining what short means. For production apps, use output contracts consistently: number of bullets, maximum sentence count, allowed fields, and forbidden extras. This reduces both output tokens and post-processing complexity.

Step 3: Put Length Limits in the Prompt and API Call

A prompt-level instruction is helpful, but an API-level limit is safer. Use both. In the prompt, write: “Answer in 120 words or fewer.” In the API request, set an appropriate maximum output token value. If your UI card can only display a short answer, do not allow the model to generate a long one.

For example, a classification task may only need 20 to 80 output tokens. A customer reply draft may need 150 to 250. A code explanation may need 300. Setting a realistic ceiling prevents runaway responses and makes monthly costs easier to forecast.

Step 4: Remove Politeness and Redundant Instructions

Human-friendly prompts often contain unnecessary filler: “Please carefully read the following text and kindly provide...” The model does not need that. Shorter instructions are usually just as effective.

Instead of: “Please act as an expert marketing analyst and carefully review the following content, then provide a helpful, concise, professional answer.”

Use: “Role: marketing analyst. Task: identify 3 conversion issues. Output: bullets only, under 60 words total.”

This saves input tokens every time the prompt runs. In high-volume workflows, shaving even 50 tokens from a repeated prompt can matter.

Step 5: Send Only Relevant Context

One common mistake is passing entire documents, full chat histories, or large code files when the model only needs a fragment. Use retrieval, truncation, or pre-filtering before the API call. For chat apps, keep a rolling summary instead of resending every message. For coding tools, send the specific function, error, and nearby context rather than the whole repository.

A useful pattern is: “Here is the only context you may use.” This discourages the model from expanding beyond the supplied information and often leads to shorter answers.

Step 6: Choose the Cheapest Model That Meets the Need

Prompt tuning is powerful, but model selection still matters. Not every task needs the largest reasoning model. Use smaller or faster models for extraction, tagging, rewriting, routing, and simple summaries. Reserve stronger models for complex reasoning, architecture decisions, or difficult code generation.

59API is useful here because it gives developers low-cost, pay-as-you-go access to multiple Claude and GPT models through a familiar OpenAI-compatible interface. You can test Claude Haiku or Sonnet for routine tasks, escalate to Opus when quality demands it, and keep the same base URL: https://api.59api.com. It is also compatible with Claude Code, Codex, and standard OpenAI SDK workflows, so switching experiments does not require a major integration rewrite.

Step 7: Use Stop Rules and Negative Instructions

If your app only needs the answer, tell the model what not to include. Add instructions such as: “Do not include an introduction,” “Do not explain your reasoning,” “Do not repeat the question,” or “Return only valid JSON.” These constraints prevent common token leaks.

For list-style outputs, you can also define a stop condition: “Return exactly 5 items.” For structured fields, require empty strings instead of explanatory notes when information is missing. This keeps responses compact and machine-readable.

Step 8: Build a Prompt Test Set

Do not optimize from one example. Create a small test set of 20 to 50 real inputs, then compare prompt versions. Track output length, accuracy, formatting failures, and average cost. A prompt that is 30% shorter but fails twice as often is not cheaper in practice.

Version your prompts like code. Keep notes such as “reduced summary from 5 bullets to 3,” “added 120-word cap,” or “removed chain-of-thought request.” Over time, this creates a reliable prompt optimization playbook for your team.

Step 9: Avoid Asking for Hidden Reasoning

Prompts such as “think step by step and explain everything” can dramatically increase output length. For many applications, you only need the final answer or a brief rationale. Use: “Think privately if needed. Return only the final answer and a one-sentence reason.” This preserves useful reasoning behavior without paying for long explanations users may never read.

Step 10: Combine Prompt Savings with Low-Cost Routing

The best cost reductions come from stacking improvements: concise prompts, capped outputs, relevant context, smaller models for simple tasks, and affordable API access. With 59API, developers can use official-quality native models through a cheap relay, avoid vendor lock-in with OpenAI-compatible SDK support, and benefit from pay-as-you-go pricing plus a referral rebate.

If you are already using Claude or GPT models, try running your optimized prompts through 59API and compare cost, speed, and output quality on your own workload. Small prompt changes often produce immediate savings, and a lower-cost relay can multiply the effect.

Final Checklist

Cheaper AI does not have to mean worse AI. In most cases, it means giving the model clearer boundaries and paying only for the tokens your product actually needs.

Tarifs · Docs

Prêt à commencer ?

Connectez Claude et GPT en quelques minutes aux prix les plus bas, sans bridage. Inscrivez-vous pour votre clé API.

Inscription gratuite