HTTP API
gerald serve listens on http://127.0.0.1:8080 (or --port). The API
follows OpenAI’s text-completion shape where it can, with one extension,
instruction.
Rules for every request
Section titled “Rules for every request”- Loopback only.
Hostmust be127.0.0.1:<port>orlocalhost:<port>. - No browsers. Any request with an
Originheader gets403. - No key. No authentication is needed or checked.
- Bodies are JSON, at most 1 MiB, and must arrive within 15 seconds.
- At most 32 connections.
Errors look like this:
{ "error": { "message": "Model busy; retry" } }GET /health
Section titled “GET /health”{ "status": "ok" }GET /v1/models
Section titled “GET /v1/models”The one served model.
{ "object": "list", "data": [ { "id": "gerald/ruby:0.2.0", "object": "model", "owned_by": "local", "capabilities": ["fim", "implement"], "sha256": "…" } ]}capabilities has fim for Tab and implement when the release has an
Implement mode.
POST /v1/completions
Section titled “POST /v1/completions”Fill-in-the-middle. prompt is the text before the cursor and suffix the
text after it.
- Tab: no
instruction. Completes the current line. - Implement: with an
instruction. Writes one method at the cursor.
| Field | Type | |
|---|---|---|
model |
string | Required. Exactly the served id |
prompt |
string | Required. Text before the cursor |
suffix |
string | Text after the cursor |
instruction |
string | 1 to 1,000 bytes. Selects Implement |
max_tokens |
integer | Capped at the mode’s limit |
temperature |
number | Default 0 |
top_p |
number | |
seed |
integer | |
stop |
string or array | Up to four strings |
stream |
boolean | Server-sent events when true |
stream_options |
object | Passed through |
Any other field is rejected with Unsupported request parameter. evidence
is reserved and refused for now.
| Tab | Implement | |
|---|---|---|
| Output limit | 64 tokens | 512 tokens |
| Stops at | The end of the line | The end that closes the method |
| Concurrency | One request | One request |
These limits come from the release; the figures are for gerald/ruby:0.2.0,
which has a 4,096 token context. Each mode has its own slot, so Tab is not
queued behind Implement. Prompts are measured before they run: one that does
not fit fails instead of being truncated. Generation times out after 120
seconds.
curl http://127.0.0.1:8080/v1/completions -H 'Content-Type: application/json' -d '{ "model": "gerald/ruby:0.2.0", "prompt": "class Cart\n def empty?\n items.", "suffix": "\n end\nend\n"}'Implement
Section titled “Implement”curl http://127.0.0.1:8080/v1/completions -H 'Content-Type: application/json' -d '{ "model": "gerald/ruby:0.2.0", "prompt": "class Cart\n ", "suffix": "\nend\n", "instruction": "Implement Cart#total: Return the amount to charge. If `coupon` is nil, return `subtotal`. Otherwise return `subtotal` minus `coupon.amount`, never below zero."}'Instructions work best as two to four plain sentences: what the method does, one sentence per condition, the names to use, and what it returns.
The reply is an OpenAI-style completion; the text is in choices[0].text.
GET /stats
Section titled “GET /stats”Counters for gerald stats: the model, device, uptime, and request and token
counts by mode. Counts and times only, never prompt or completion text.
Status codes
Section titled “Status codes”| Code | Message | |
|---|---|---|
400 |
Unsupported request parameter, Unknown model, Prompt is required, Instruction must be 1 to 1,000 bytes of text, Invalid stop sequences, Text contains reserved control tokens, Output budget exceeds context |
Fix the request |
400 |
This model supports FIM; use /v1/completions |
Chat is not served |
403 |
Loopback clients only |
Wrong Host, or an Origin header |
404 |
Unknown endpoint |
|
413 |
Request too large or incomplete |
|
429 |
Model busy; retry |
That mode is serving another request |