KoboldAI API in KoboldCpp: generate, stream and extras

The KoboldAI API is the native API of KoboldCpp, served at http://localhost:5001/api/v1 with KoboldCpp's own additions under /api/extra. It is free and local: there is no account, and no key unless the server was started with --password. Apps that offer a KoboldAI or KoboldCpp connection want just http://localhost:5001. Text generation is a POST to /api/v1/generate; streaming uses /api/extra/generate/stream.

Checked against KoboldCpp 1.124.2 · updated 13 Nov 2026
  • lab-lnx: Linux test VM · 4 vCPU · 15 GB · no GPU
How we test
On this page
  1. KoboldAI API: the original and KoboldCpp
  2. All the native routes
  3. Generate text
  4. Generation parameters
  5. Streaming with SSE
  6. Check progress and abort
  7. Server info
  8. Tokens and logprobs
  9. Saves, preloaded stories and multiplayer
  10. Admin endpoints
  11. Authentication

KoboldAI API: the original and KoboldCpp

The original KoboldAI client is legacy, and its project points people to KoboldCpp (the difference). KoboldCpp serves the same /api/v1 routes and reports API version 1.2.5, which is the KoboldAI API version and not its own F24. The soft-prompt routes only exist for compatibility.

API tester

Send a request to your own KoboldCpp.

Runs in your browser. Nothing is uploaded.

Requests go from your browser straight to the address you typed. Nothing is sent to koboldcpp.dev, and the password is never put in a share link.

All the native routes

KoboldCpp API routes
Main parameters
POST/api/v1/generate
also /api/latest/generate
KoboldAIClassic KoboldAI text generation: prompt plus sampler settings, returns the full result.max_context_length max_length prompt rep_pen rep_pen_range sampler_orderyesworks F23
GET/api/v1/model
also /api/latest/model
KoboldAIName of the loaded text model (masked when a password is set and not supplied).–yesworks F23
GET/api/v1/config/max_length
also /api/latest/config/max_length
KoboldAIDefault generation length the server advertises.–yesworks F23
GET/api/v1/config/max_context_length
also /api/latest/config/max_context_length
KoboldAIContext length the server advertises to clients.–yesworks F23
GET/api/v1/config/soft_prompt
also /api/latest/config/soft_prompt
KoboldAIStub kept for KoboldAI client compatibility (soft prompts not supported).–nountested
GET/api/v1/config/soft_prompts_list
also /api/latest/config/soft_prompts_list
KoboldAIStub returning an empty soft-prompt list for compatibility.–nountested
GET/api/v1/info/version
also /api/latest/info/version
KoboldAIKoboldAI United API version that KoboldCpp emulates.–yesworks F23
GET/api/v1KoboldAIBare API root; redirects (302) to the /api docs page.–nountested
POST/api/extra/generate/streamExtraSame as /api/v1/generate but streams tokens as Server-Sent Events.max_context_length max_length prompt rep_pen rep_pen_range sampler_orderyesworks F23
GET/api/extra/generate/checkExtraReturns the partial text of the generation in progress.–yesuntested
POST/api/extra/generate/checkExtraPartial text of an in-progress generation identified by genkey (multi-user safe).genkeyyesuntested
POST/api/extra/abortExtraStops the current generation (optionally only for a given genkey).genkeyyesuntested
GET/api/extra/versionExtraKoboldCpp version and a feature/capability list (vision, audio, image gen, TTS, etc.).–yesworks F23
GET/api/extra/true_max_context_lengthExtraThe real --contextsize loaded at launch (not advertised to Horde).–yesworks F23
GET/api/extra/perfExtraTiming and usage statistics of recent generations, queue state, uptime.–yesworks F23
GET/api/extra/last_logprobsExtraToken log-probabilities of the latest request.–yesuntested
POST/api/extra/last_logprobsExtraToken log-probabilities for the request with a given genkey.genkeyyesuntested
POST/api/extra/tokencount
also /api/extra/tokenize
ExtraTokenizes text and returns the token count and ids.promptyesworks F23
POST/api/extra/detokenizeExtraTurns a list of token ids back into text.idsyesuntested
POST/api/extra/json_to_grammarExtraConverts a JSON schema into a GBNF grammar for constrained sampling.schemayesuntested
GET/api/extra/preloadstoryExtraReturns the story preloaded with --preloadstory.–yesuntested
POST/api/extra/websearchExtraRuns a DuckDuckGo web search through the server (needs --websearch) and returns top results.qyesuntested
POST/api/extra/data/listExtraLists save slots in the server-side save database (--savedatafile).–yesuntested
POST/api/extra/data/loadExtraLoads a save slot from the server-side database.slotyesuntested
POST/api/extra/data/saveExtraWrites data to a server-side save slot.slot format title datayesuntested
POST/api/extra/multiplayer/statusExtraMultiplayer session turn info (--multiplayer).senderbusy senderyesuntested
POST/api/extra/multiplayer/getstoryExtraFetches the shared multiplayer story (compressed).–yesuntested
POST/api/extra/multiplayer/setstoryExtraUpdates the shared multiplayer story and advances the turn.full_update sender data_format datayesuntested
POST/api/extra/shutdownAdminShuts the server down (only allowed in specific setups; password-protected).–yesuntested
POST/api/extra/embeddingsExtraNative embeddings endpoint.model input truncateyesuntested
GET/api/admin/list_optionsAdminLists .kcpps/.kcppt/.gguf choices in --admindir.–yesuntested
POST/api/admin/reload_configAdminSwitches to another config/model in --admindir (or unloads); restarts the backend.filename baseconfigyesuntested
POST/api/admin/check_stateAdminSize of existing KV save states and the prediction for a new one.–yesuntested
POST/api/admin/save_stateAdminSaves the current KV cache to a memory slot.slotyesuntested
POST/api/admin/load_stateAdminRestores a saved KV cache slot.slotyesuntested
POST/api/admin/clear_stateAdminFrees all KV save states.–yesuntested
GET/.well-known/serviceinfoExtraService identity document listing which APIs this server provides.–yesuntested
GET/pingExtraHealth check for serverless hosts (added v1.97).–nountested
OPTIONS*ExtraCORS preflight / header-only responses for any path.–nountested
HEAD*ExtraCORS preflight / header-only responses for any path.–nountested

Generate text

POST /api/v1/generate (also /api/latest/generate). We sent a prompt and read the answer F85:

Request
{
"prompt": "Hello",
"max_length": 8,
"temperature": 0,
"max_context_length": 2048
}
Response, KoboldCpp 1.124.2
{
"results": [{
  "text": "\n\nI am trying to create a simple",
  "tool_calls": [],
  "finish_reason": "length",
  "logprobs": null,
  "prompt_tokens": 1,
  "completion_tokens": 8
}]
}

Generation parameters

The server publishes its own spec at /api?json=1. We saved it and built this table from it; the descriptions are ours. Sampler meanings are on the settings page. If a request leaves max_length out the server uses 2048 F05.

Parameters of POST /api/v1/generate, from the spec captured on 2026-11-14 (KoboldCpp 2026.11.01)
max_context_lengthintegernot setKoboldAI tooHow many tokens of the prompt the server may use. Send the same number the server was started with.
max_lengthintegernot setKoboldAI tooHow many tokens to write. The server default is 2048 when this is left out.
promptstringnot setKoboldAI tooThe text to continue. Everything the model should see goes here.
rep_pennumbernot setKoboldAI tooRepetition penalty. 1.0 means none.
rep_pen_rangeintegernot setKoboldAI tooHow many of the latest tokens the repetition penalty looks at.
sampler_orderarraynot setKoboldAI tooThe order the samplers run in. Leave it alone unless a guide for your model says otherwise.
sampler_seedintegernot setKoboldAI tooA number that makes sampling repeatable on one machine.
stop_sequencearraynot setKoboldAI tooStrings that end the reply when the model writes them.
temperaturenumbernot setKoboldAI tooHow random the choice of the next word is. 0 always takes the likeliest.
tfsnumbernot setKoboldAI tooTail free sampling, a way to cut unlikely words. 1 turns it off.
top_anumbernot setKoboldAI tooTop-a sampling. 0 turns it off.
top_kintegernot setKoboldAI tooKeep only this many likeliest words. 0 turns it off.
top_pnumbernot setKoboldAI tooKeep the smallest group of words whose chances add up to this. 1 turns it off.
min_pnumbernot setKoboldAI tooDrop words whose chance is below this share of the likeliest word.
typicalnumbernot setKoboldAI tooTypical sampling. 1 turns it off.
use_default_badwordsidsbooleanfalseKoboldAI tooWhen true, the end-of-text token cannot be written.
dynatemp_rangenumber0KoboldAI tooA range around the temperature that varies with the model certainty. 0 turns it off.
smoothing_factornumber0KoboldAI tooReshapes the chances around the top word. 0 turns it off.
dynatemp_exponentnumber1KoboldAI tooExponent used by dynamic temperature.
mirostatnumbernot setKoboldCpp onlyMirostat mode: 0 off, 1 or 2 on.
mirostat_taunumbernot setKoboldCpp onlyMirostat target surprise.
mirostat_etanumbernot setKoboldCpp onlyMirostat learning rate.
genkeystringnot setKoboldCpp onlyA key you choose, so check and abort calls reach your own request on a shared server.
grammarstringnot setKoboldCpp onlyA GBNF grammar the reply must follow.
grammar_retain_statebooleanfalseKoboldCpp onlyKeep the grammar state from the previous request.
memorystringnot setKoboldCpp onlyText that is always put at the very start of the prompt.
imagesarraynot setKoboldCpp onlyBase64 images for a vision model.
trim_stopbooleantrueKoboldCpp onlyRemove a matched stop sequence from the returned text.
render_specialbooleanfalseKoboldCpp onlyShow special tokens in the returned text.
bypass_eosbooleanfalseKoboldCpp onlyAllow the end-of-text token to be written.
banned_tokensarraynot setKoboldAI tooStrings that must not appear in the reply.
logit_biasobject[object Object]KoboldCpp onlyRaise or lower the chance of chosen token ids.
dry_multipliernumbernot setKoboldCpp onlyDRY strength. 0 turns it off.
dry_basenumbernot setKoboldCpp onlyDRY base: how fast the penalty grows with repeat length.
dry_allowed_lengthnumbernot setKoboldCpp onlyRepeats up to this length are not penalised.
dry_penalty_last_nnumbernot setKoboldCpp onlyHow many latest tokens DRY looks at.
dry_sequence_breakersarraynot setKoboldAI tooStrings that stop DRY from counting a repeat.
xtc_thresholdnumbernot setKoboldCpp onlyXTC: words above this chance can be removed.
xtc_probabilitynumbernot setKoboldCpp onlyXTC: how often the removal happens. 0 turns it off.
nsigmanumbernot setKoboldCpp onlyTop-n-sigma sampling. 0 turns it off.
logprobsbooleanfalseKoboldAI tooReturn the top token chances for each generated token.
replace_instruct_placeholdersbooleanfalseKoboldAI tooSwap the instruct placeholders in the prompt for the tags of the loaded template.

Streaming with SSE

POST /api/extra/generate/stream takes the same body and answers with server-sent events. For 12 requested tokens we received 6 events, the first with several tokens, and the last with an empty token and a finish reason F85:

Stream, first and last eventsF85 · KoboldCpp 1.124.2
event: messagedata: {"token": " 4, 5,", "finish_reason": null}1…event: messagedata: {"token": "", "finish_reason": "length"}2
  1. data: {"token": " 4, 5,", "finish_reason": null}: A chunk can hold more than one token.
  2. data: {"token": "", "finish_reason": "length"}: The last event: the reason the reply ended.

Check progress and abort

While a request runs, POST /api/extra/generate/check with its genkey returns the text so far (732 characters after 5 seconds in our test). POST /api/extra/abort with the same genkey stops it: it answered {"success":"true","done":"true"} and the waiting generate call ended with 705 characters of partial text and status 200 F85.

The genkey is a string you choose and send with the generate call. It keeps your check and abort calls separate from other people’s on a shared server.

Server info

Info routes, answers captured on KoboldCpp 1.124.2
/api/v1/modelkoboldcpp/<model file name>
/api/v1/config/max_length{"value": 2048}
/api/v1/config/max_context_lengththe context size the server started with
/api/extra/true_max_context_lengththe same value on our run
/api/v1/info/version{"result": "1.2.5"} (the API version)
/api/extra/versionKoboldCpp, 1.124.2 and flags such as llm, jinja, savedata, admin
/api/extra/perflast speeds, queue, uptime (34.6 tokens per second for our 8-token request)

Tokens and logprobs

  • Count: POST /api/extra/tokencount with {"prompt": "Hello world"} returned value: 3 and the token ids; /api/extra/tokenize is an alias. Note that the first id was the end-of-text token (151643) on this model.
  • Decode: POST /api/extra/detokenize with {"ids": [...]} returned result and success.
  • Logprobs: send "logprobs": true and the answer carries logprobs.content with top_logprobs per token. /api/extra/last_logprobs (GET, or POST with a genkey) returns the latest. At temperature 0 every value we saw was 0.0.
  • Grammar: POST /api/extra/json_to_grammar turns a JSON schema into GBNF text you can pass as grammar.

All captured on the 0.5B test model F85.

Saves, preloaded stories and multiplayer

/api/extra/data/* needs (1.85), /api/extra/preloadstory needs , and /api/extra/multiplayer/* needs (1.79). We ran them only without their flags, where preloadstory answered {}. See multiplayer.

Admin endpoints

/api/admin/* (list options, reload config, save and load KV states) needs with ; protect it with . Without them list_options answered an empty list in our run F85.

Authentication

With clients send Authorization: Bearer <key>. It protects generation, not discovery F25. Details: the API page.

Frequently asked questions

Is the KoboldAI API free?

Yes. It is part of the KoboldCpp program on your own computer. There is no account and no charge.

What is the KoboldAI API URL?

http://localhost:5001 for most apps, or http://localhost:5001/api/v1 where an app asks for the full path. From another computer, use the address of the PC running KoboldCpp.

Where do I get a KoboldAI API key?

There is none by default. A key exists only if you start KoboldCpp with --password, and then clients send it as a Bearer header.

How do I stream tokens?

POST the same body as generate to /api/extra/generate/stream. The reply is a stream of events, each with a data line holding token and finish_reason; the last has finish_reason set.

Is this the same API as the old KoboldAI?

It is the same shape: KoboldCpp reports API version 1.2.5 at /api/v1/info/version, as the original did. KoboldCpp adds parameters and the /api/extra routes.

How do I stop a generation?

POST /api/extra/abort. On a shared server include the genkey you sent with the request. In our test the waiting generate call ended with the partial text.