EN ▾
Start now

apiinference.com/Notes

Inference API Meaning: Inference vs Training

Inference is the stage where a trained model answers a new prompt, and an inference API is the web endpoint that exposes that stage. Here is how it differs from training and what you get.

Last updated

Glass vault with a glowing crystal lattice, a prompt bubble entering and an answer bubble leaving on a conveyor

Summary

  • Training builds a model; inference uses a finished one to answer prompts.
  • An inference API sells inference as a service: you send text, you get text.
  • You get no control over the weights; fine-tuning is a separate product.
  • Output tokens usually cost more than input tokens because they are produced one at a time.

Inference versus training

The inference api meaning rests on one distinction. A model goes through two life stages. In training, a large system reads huge amounts of text and adjusts billions of numeric weights until it predicts text well. That takes weeks and a lot of hardware. In inference, those weights are frozen and the model is used: you give it a prompt, and it produces an answer. Inference is what happens every time you chat with a bot.

An inference API is a service that runs the second stage for you. It hosts a finished model on GPUs, wraps it in an HTTP endpoint, checks your key and bills you for the tokens you use. You never see the weights or the servers.

Training, fine-tuning and inference side by side

StageWhat happensWho does itOn this API
TrainingWeights are learned from scratch on huge text setsThe model's authorsNot offered
Fine-tuningAn existing model is adjusted on your own examplesYou or a providerNot offered
InferenceA finished model answers a promptThe API providerThis is the product

If you want a model that behaves differently, you have two lighter options without fine-tuning: write a better system prompt, or put examples in the prompt itself.

What happens inside one inference call

When your request arrives, the provider does roughly this:

  1. Splits your text into tokens, small chunks the model understands.
  2. Reads all input tokens in one pass, which is the cheap and fast part.
  3. Generates the answer one token at a time, feeding each new token back in to choose the next.
  4. Stops when the model finishes, when a stop sequence appears, or when a limit is reached.

Step 3 is why output tokens typically cost more than input tokens, and it is why long answers take longer. Here the rates are $0.15 per 1M input tokens and $0.50 per 1M output tokens. Reading a 10,000-token document costs $0.0015, while writing a 1,000-token reply costs $0.0005, so the reply is a smaller line item than the document even at the higher rate.

What you get from a hosted text endpoint

The practical benefits are short:

  • No hardware: you do not rent or maintain GPUs.
  • A standard interface: the API follows the OpenAI format, so existing SDKs and tools work after you change the base URL and key.
  • Pay per use: prepaid credit, no subscription, and failed or refused requests are not charged.
  • Features you would otherwise build: streaming, tool calling, JSON mode and sampling controls such as temperature, top_p and seed.

Streaming deserves a quick demo, because it shows inference happening token by token. Run this and watch the chunks arrive:

curl https://api.apiinference.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "stream": true,
    "messages": [{"role": "user", "content": "Name three uses of a hash map."}]
  }'

Each line starting with data: carries a small piece of the answer, and usage arrives at the end.

You still have real levers over the output. The system message sets role and tone. Examples placed in the prompt show the format you want. temperature controls variety, stop ends the answer at a chosen string, seed makes runs more repeatable, and max_tokens caps length. None of these change the weights; they change how you use the same model.

The two speeds: latency and throughput

When people talk about how fast inference is, they mean two different things, and a hosted endpoint affects both.

Latency: how soon you see the first word

Latency is the wait between sending a request and getting the start of the answer. It grows with the size of the prompt, because the model has to read all of it first. It also depends on how busy the service is. If you stream, the first words appear while the rest is still being generated, which feels faster even when total time is the same.

Throughput: how much work per minute

Throughput is how many requests or tokens you can push through in a given time. On a hosted API your ceiling is set by your key's limits: a full key allows 8 concurrent requests and 300 per minute, while a trial key allows 2 and 60. Because a streamed request holds its concurrency slot until the stream ends, long answers lower the number you can finish per minute. With 8 slots and answers that take 20 seconds each, you can complete at most 24 per minute (8 x 60 / 20).

This API does not publish latency figures, so measure your own with your own prompts. The docs explain how the limit errors are labeled so your client can react to them.

Reading the usage numbers

Each response includes a usage block, and it is the best way to see inference as a metered service. It lists the input tokens (prompt_tokens), the output tokens (completion_tokens) and their total. Those two figures are what you are billed on.

Say a call reports 1,200 prompt tokens and 350 completion tokens. Input costs 1,200 x $0.15 / 1,000,000 = $0.00018. Output costs 350 x $0.50 / 1,000,000 = $0.000175. The call costs $0.000355. Multiply by the number of calls you expect and you have a forecast with no guesswork.

Two further points help. First, the prompt tokens include everything you send: system message, earlier turns, and any pasted documents. A chat that has run for a while is mostly input. Second, the same text can split into different token counts for different models, so token counts from one provider will not match another's exactly.

A common misconception is that inference teaches the model from your prompts. It does not: the weights are frozen at this stage. On this service prompts are also not used for training, which is a policy statement, separate from how inference works.

What you do not get

A hosted endpoint is a rental, not ownership. You cannot download or change the weights, and you cannot train on top of them here. The model is one open-weight model run by an independent provider, so you also cannot pick from a catalog or route between vendors. It is text only: no image, audio or video generation, and no embeddings.

It also does not remember. Each call stands alone, so a conversation works only because your code sends the earlier messages again. With a 100,000-token window shared between prompt and completion, that is generous but finite.

Choosing between self-hosting and an inference API

You can run inference yourself with open-weight models on your own GPU. That gives you full control and no per-token bill, but you handle drivers, memory limits, batching and uptime. An inference API trades that control for convenience. For small and medium workloads, the API is usually less work. For very heavy, steady load, compare your own hardware cost against the token bill.

If an API fits, the next step is practical. Read the docs for parameters and limits, check the pricing, and claim trial credit on the API key page. The site's guide for adult-use workloads goes deeper on the content side.

01

Common questions

What is the difference between inference and training?

Training teaches a model by adjusting its weights on large text sets. Inference uses the finished weights to answer a prompt, with no learning involved.

Is fine-tuning part of an inference API?

Not here. This API serves one model for inference only, with no fine-tuning offered.

Why do output tokens cost more than input tokens?

Input is processed in one pass, while output is generated one token at a time. On this API the rates are $0.15 per 1M input and $0.50 per 1M output.

Does an inference API store my prompts for training?

Prompts sent to this API are not used for training.

Generate your key now

Sign up, copy the key, update your base URL. That is the entire configuration.

apiinference.com

Start with trial credit

Email and password, key displayed immediately.

View documentation