Fine-tuning
Last updated: 2026-11-21T09:07:48-03:00 (UTC-3)
Create and monitor fine-tuning jobs on the OpenAI API through the gateway, with files and jobs isolated per team. Flags: fine_tuning and batches. Interactive reference at /docs/swagger/, tag Fine-tuning.
How to turn it on
Section titled “How to turn it on”-
Turn on the
fine_tuningandbatchesflags. Both require storage. -
Declare an alias with the
fine_tuningcapability. The first target must use theopenaiprotocol:models:- id: ft-minicapabilities: [chat, fine_tuning]targets:- {provider: openai, model: gpt-4o-mini-2024-07-18} -
Give the key the
batches:writescope, to upload files, androute:fine_tuning, plus the alias in its allowlist. The key must belong to a team.
How to use it
Section titled “How to use it”client = openai.OpenAI(api_key=KEY, base_url="https://gateway.example.com/v1")f = client.files.create(file=open("train.jsonl", "rb"), purpose="fine-tune")job = client.fine_tuning.jobs.create(model="ft-mini", training_file=f.id, metadata={"run": "nightly"})client.fine_tuning.jobs.retrieve(job.id)client.fine_tuning.jobs.list_events(job.id, limit=10)client.fine_tuning.jobs.cancel(job.id)How it works
Section titled “How it works”| Aspect | Behavior |
|---|---|
| Target | The alias’s first target, with no fallback. The connection and the upstream model are recorded in the job |
| Files | fine-tune files from the key’s team, as JSONL of objects. The gateway copies the file to the provider when the job is created and deletes the copy when the job finishes or is rejected |
| Isolation | A job from another team, a forged ID or a raw ID from the provider account return 404, without calling the provider |
| Listing | Only the team’s jobs, paginated by the gateway (after, limit from 1 to 100, has_more). It never uses the provider account’s list. Accepts a metadata[k]=v filter |
| Object | Shows the alias in model and the gateway’s file IDs. Status, fine_tuned_model and trained_tokens come from the provider |
| Errors | A provider rejection arrives as it came (status and body) |
| Rejected | integrations, because the W&B integration belongs to the provider organization |
| Usage | Each call enters the ledger as fine_tuning, with no tokens. Training is billed by the provider, outside budget and TPM |
| Console | The Fine-tuning screen: jobs per team, with the last reported state and cancellation for the team admin |
Using the trained model
Section titled “Using the trained model”When the job finishes, fine_tuned_model carries the ID at the provider (ft:...). To call it through the gateway, the operator creates an alias with that ID as the target model.
Limits
Section titled “Limits”- OpenAI is shutting down self-serve fine-tuning. New organizations can no longer create jobs since May 2026, and the general end is planned for January 2027; inference on already-trained models continues. For that reason, a real end-to-end job was not run.
- Providers with an OpenAI-compatible API follow the same path, but none has been validated. Azure OpenAI and Vertex are not supported yet.
result_filescarries provider file IDs, which the gateway’s Files API does not read.- Revoking the key does not cancel the job at the provider; cancel it explicitly.
- The file copies at the provider are deleted when a retrieve, list or cancel call observes that the job has ended.
Admin API routes
Section titled “Admin API routes”Every route below needs a console session or an admin Bearer token, the role’s permission and, for writes, the X-CSRF-Token header; the full contract is in the API reference.
| Route | What it does |
|---|---|
GET /api/v1/admin/fine-tuning/jobs |
Lists the fine-tuning jobs the gateway owns, with the last state the provider reported and the trained model |
POST /api/v1/admin/fine-tuning/jobs/{id}/cancel |
Cancels the job at its provider |