EN ▾
Get API key

Cheapest Coding LLM API: Real Cost per Task

The cheapest coding llm api is the one whose per-task cost you can calculate before you ship. Here is that calculation for code review, refactors and agent loops at $0.15 per 1M input and $0.50 per 1M output tokens.

Updated

Glass pipeline feeding code brackets and coins into a low-reading meter, illustrating cheap coding API cost
Abstract chat bot figure surrounded by glowing speech bubbles, illustrating a Discord bot powered by an LLM API

Key points

  • Rates are $0.15 per 1M input tokens and $0.50 per 1M output tokens, prepaid, no subscription.
  • A 5,000-token code review with an 800-token answer costs about $0.00115.
  • Agent loops cost the most because every step resends the growing context, so trim history.
  • Failed or refused requests are not charged, and credit never expires.

How to judge the cheapest coding LLM API

A price per million tokens means little until you map it onto the work you actually do. Coding is input-heavy: you paste files, diffs, stack traces and test output, and you get back a patch or an explanation that is much shorter. So the input rate matters more than the output rate for most developer workloads, and the number of times you resend the same context matters more than either.

This API charges $0.15 per 1M input tokens and $0.50 per 1M output tokens. It is pay as you go from prepaid credit. There is no subscription, the credit never expires, and a request that fails or is refused is not billed. Other providers change their prices often, so check their current pricing next to these figures instead of trusting a table from last quarter.

One caveat on scope: this is one open-weight text model, not a menu of models. If you need a specific frontier model, this is not a substitute for it. If you need a general coding model that answers without content refusals for lawful adult use, read on. The page on the uncensored AI model for coding explains what that means in practice.

The formula and a rough token budget

Cost per request is simple:

cost = input_tokens * 0.15 / 1,000,000 + output_tokens * 0.50 / 1,000,000

For token counts, use a rough rule: one token is about four characters of English or about three to four characters of code. A 300-line source file with typical line lengths lands around 3,000 to 4,000 tokens. Your own numbers will differ, so read the usage block in a real response and replace my estimates with measured ones. The response reports prompt and completion tokens, and the X-Balance-USD header shows your balance after each call.

The estimates below are assumptions, not benchmarks. Treat them as a template.

Worked costs for common coding tasks

TaskInput tokensOutput tokensCost
Review one file5,000800$0.00115
Multi-file refactor30,0006,000$0.0075
Explain a stack trace2,000500$0.00055
Fill the whole 100k window once100,0004,000$0.017

Check the first row: 5,000 x $0.15 / 1M = $0.00075, and 800 x $0.50 / 1M = $0.0004. Sum: $0.00115. At that rate 1,000 file reviews cost $1.15.

The refactor row: 30,000 x $0.15 / 1M = $0.0045, plus 6,000 x $0.50 / 1M = $0.003, giving $0.0075. A hundred of those is $0.75.

The last row shows the ceiling for one call. The context window is 100,000 tokens, prompt and completion together. Sending a nearly full window costs $0.015 for input, and a 4,000-token answer adds $0.002. Even your biggest single request stays under two cents.

Agent loops: where the bill actually grows

A coding agent calls the model repeatedly. Each step sends the full conversation again: system prompt, tool definitions, earlier tool results and the new observation. Input grows with every step, so cost is not linear in the number of steps.

Take a run of 20 steps where the context grows from 4,000 tokens at step one to 40,000 at step twenty. The average is about 22,000 tokens per call, so total input is roughly 440,000 tokens: 440,000 x $0.15 / 1M = $0.066. If each step produces about 500 tokens (a tool call and a short note), output is 10,000 tokens: $0.005. One agent run lands near $0.071.

That means a $20 top-up covers about 281 such runs (20 / 0.071). A team doing 200 runs a month spends around $14.20. These are modest numbers, but they scale with context length, which is the lever you control. The tool-calling flow itself is covered in the article on using an LLM API from VS Code and in the API docs.

Five ways to cut the bill further

  • Send diffs, not files. A 60-line diff is a fraction of a 600-line file, and the model usually needs only the changed hunks plus a signature or two.
  • Truncate tool output. Test logs and grep results are the usual culprits. Keep the last 100 lines or the failing test, not everything.
  • Drop old steps. After a sub-task finishes, replace its raw transcript with a two-line summary. If that keeps the context near 20,000 tokens instead of letting it climb to 40,000, the late steps of a run cost half as much on input.
  • Set max_tokens for chatty tasks. It is optional here, but a cap keeps a rambling answer from costing output rates for no reason.
  • Use a low temperature for patches. Fewer retries mean fewer billed calls.

None of this needs special support. Parameters like temperature, top_p, stop and seed are passed through.

Measuring your own cost per task

Log the usage numbers for a week and you will know your real figure. This snippet prints the cost of each call from the response:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.codingllmapi.com/v1",
    api_key="YOUR_KEY",
)

resp = client.chat.completions.create(
    model="uncensored",
    messages=[
        {"role": "system", "content": "You are a careful code reviewer."},
        {"role": "user", "content": open("app.py").read()},
    ],
    temperature=0.2,
)

u = resp.usage
cost = u.prompt_tokens * 0.15 / 1e6 + u.completion_tokens * 0.50 / 1e6
print(resp.choices[0].message.content)
print(f"cost: ${cost:.5f}")

New accounts can claim $0.50 of trial credit with one click on the API key page. At the review price above, that is enough for roughly 430 file reviews before you pay anything. The trial is valid for 7 days, needs no card and is limited to one per person.

Top-ups, bonuses and what to buy

Top-ups are any whole amount from $20 to $500. Larger ones earn a bonus: +5% from $50, +10% from $100 and +15% from $200. A $200 top-up therefore gives $230 of credit. At the agent-run cost of $0.071, that is over 3,200 runs. You can pay with crypto (USDT on TRC20, USDC on Base). Full details are on the pricing page.

Limits matter for cost too, because they decide how fast a batch can run. A full key allows 8 concurrent requests and 300 requests per minute; a trial key allows 2 and 60. If you exceed either, you get HTTP 429 with the code rate_limited or concurrency, and a temporary overload returns 429 with Retry-After: 5. Back off and retry; rejected requests are not charged.

Making answers feel better

Once the basic loop works, a few small changes improve it a lot.

  • Stream the answer. Pass stream=True and edit the bot's message every second or so with the text so far. Do not edit on every token, because Discord applies its own rate limits to message edits. A streamed request holds its concurrency slot until it ends, so keep the semaphore around the whole stream.
  • Use slash commands. A command like /ask avoids the mention parsing and does not need the Message Content intent at all, which also makes the bot easier to verify later if it grows past a small number of servers.
  • Per-user history. Key the history by channel and user if several people ask unrelated questions in one channel.
  • Tune the system prompt. Name the languages your community uses, ask for short answers, and tell the model to ask a clarifying question when the problem is vague. Prompt changes are free and often beat model changes.
  • Lower the temperature. For code, values between 0.2 and 0.4 give steadier results than the default.

Troubleshooting the usual failures

When a new bot stays silent, the cause is almost always one of the items below. Check them in this order.

  1. The bot is online but never replies. The Message Content intent is off in the developer portal, or intents.message_content = True is missing from the code. Both must be set.
  2. It replies in some channels only. The bot lacks permission to read or send messages in the others. Check the channel's permission overrides, not only the server-wide role.
  3. Every reply is a "busy" message. You are probably hitting a 429. Print the exception body once. If the code says rate_limited, you passed the per-minute cap of 300 requests on a full key or 60 on a trial key. If it says concurrency, lower the semaphore size.
  4. An authentication error appears at the first call. The LLM key is missing from the environment of the process that runs the bot. A key exported in one terminal tab is not visible to a service started elsewhere.
  5. The answer is cut off. The max_tokens=900 in the sample stops long replies. Raise it, or remove it, since max_tokens is optional and the completion may use the rest of the window.
  6. The bot answers its own messages. That loop happens if you drop the message.author.bot check. Keep it.

For debugging, log the X-Request-Id value for each call. With the OpenAI SDK you can read it from the raw response by calling llm.chat.completions.with_raw_response.create(...) and then reading .headers. If you contact support about a specific failure, that ID lets them find the exact request.

What this costs to run

Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, with no subscription. Take a typical exchange: the system prompt plus twelve history entries make about 2,500 input tokens, and the answer is about 400 tokens.

Input: 2,500 x $0.15 / 1,000,000 = $0.000375. Output: 400 x $0.50 / 1,000,000 = $0.0002. One answer costs about $0.000575. A community that asks 500 questions in a day would spend 500 x $0.000575 = $0.2875, a little under thirty cents. Your numbers will differ with longer code pastes, so log resp.usage for a week and read the real averages. The pricing page shows the top-up options: any whole amount from $20 to $500, with +5% from $50, +10% from $100 and +15% from $200, paid by crypto.

To limit abuse, add a per-user cooldown and a cap on question length. Those two checks protect your balance better than anything else you can add.

Hosting and safety notes

The bot is a long-running process. A small virtual machine or a container host is enough, since the heavy work happens on the API side. Run it under a process manager so it restarts after a crash, and keep both tokens in environment variables or a secrets store, never in the repository.

Think about what your server allows. The model is tuned to answer without content refusals for lawful adult use, so it will discuss security testing or edgy fiction that a stricter assistant might refuse. If your community includes younger members, set rules in the system prompt, restrict the bot to specific channels, and remember that Discord's own terms apply to your bot too. Content sexualizing minors is forbidden on this API without exception.

Full parameter details, such as stop, seed and tool calling, are in the API docs. If you want the bot to run code or read repositories, tool calling is the route, and you decide which functions the model may request. For programming-focused use of this model, see the page about the uncensored AI model for coding.

Questions and answers

Is this the cheapest coding LLM API available?

I cannot verify other providers' current prices, so check them yourself. What I can give is exact math: $0.15 per 1M input and $0.50 per 1M output, which puts a typical file review at about a tenth of a cent.

Does the 100k context window make requests more expensive?

Only if you fill it. You pay for tokens actually sent and generated, so a short prompt costs little even though the window is large.

Am I charged for failed requests?

No. Failed or refused requests are not charged, and credit never expires.

Can I use it with existing OpenAI-based tools?

Yes. Change the base URL to https://api.codingllmapi.com/v1, use your key and set the model to uncensored.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key