Skip to content
Migration

Migrate from OpenAI fine-tuning to open models

Download your OpenAI fine-tuning data, import it into Tensorant, train an open model, compare it with your GPT-4o fine-tune and switch your app's base_url.

By Tensorant13 min readIntermediateUpdated

What you will build

Train an open model on your OpenAI fine-tuning data, score it against your current fine-tune on the same test set, and point your application at it.

Steps in this guide

OpenAI is winding down its fine-tuning platform. Existing customers can't create new fine-tuning jobs from January 6, 2027, and fine-tuned GPT-4o, GPT-4o mini, GPT-4.1 and GPT-4.1 mini models stop answering on January 14, 2027, when their base models shut down.

As an alternative to OpenAI fine-tuning, this guide moves one fine-tune to an open model on Tensorant. You download the fine-tune's training and validation files, import them into a project, train a LoRA adapter on an open model, score it and your OpenAI fine-tune on the same test examples, and then change your application's base URL. The OpenAI fine-tuning migration overview has the whole timeline.

Before you start

  • An OpenAI API key, exported as OPENAI_API_KEY, that can read your organization's fine-tuning jobs and files. The commands below also use curl and jq.
  • The Tensorant CLI, installed as the CLI quickstart shows, and signed in with tensorant auth login --level full. Build access is enough to import, review and evaluate, but training and test sessions need Full access.
  • Tensorant compute with credits. An owner adds credits under Settings, Plan and billing; the first payment turns Tensorant compute on. See Credits.
  • An owner of your Tensorant organization, who adds the OpenAI endpoint in step 6, and publishes the model and creates an API key in step 11.
  • One Tensorant project for each fine-tune you move. A project has one base model and its own data.

1. List your fine-tuned models and their files

Each OpenAI fine-tuning job records the base model, the fine-tuned model's ID, and the IDs of its training and validation files. Save your organization's jobs to a file and print those fields:

bash
curl -sS https://api.openai.com/v1/fine_tuning/jobs \
  -H "Authorization: Bearer $OPENAI_API_KEY" -o jobs.json
jq -r '.data[] | [.id, .model, .fine_tuned_model, .training_file, .validation_file] | @tsv' jobs.json

Each line shows the job ID, the base model, the fine-tuned model's ID (it starts with ft:), the training file's ID and the validation file's ID. A job that is still running has no fine-tuned model yet, and a job trained without a validation file shows an empty last column.

OpenAI returns 20 jobs at a time unless you set limit. If jq .has_more jobs.json prints true, request the next page from https://api.openai.com/v1/fine_tuning/jobs?after=LAST_JOB_ID, with the ID of the last job listed.

Keep this list. A fine-tune of GPT-4o, GPT-4o mini, GPT-4.1 or GPT-4.1 mini stops answering on January 14, 2027, and step 6 needs its ID while it still answers.

2. Download the training and validation files

Download each file by its ID:

bash
curl -sSf https://api.openai.com/v1/files/$FILE_ID/content \
  -H "Authorization: Bearer $OPENAI_API_KEY" -o train.jsonl

Run it again with the validation file's ID and -o validation.jsonl. The -f flag makes curl stop with an error when OpenAI refuses the request, instead of saving the error message as your file.

OpenAI may refuse to return a file's content. If it does, use the copy you uploaded from: your repository, bucket or data pipeline.

Keep the validation file. OpenAI's API reference says the validation file's data is used to generate validation metrics during fine-tuning, and that the same data should not be in both the training and validation files. You import it as the test set in step 4, so both models are scored on examples kept out of training.

If a job had no validation file, collect examples that neither model has seen, such as recent requests your team answered by hand, and use them as the test set. Your OpenAI fine-tune has already learned from the rows of its training file, so a test set taken from that file favors it.

3. Prepare the rows Tensorant reads

Tensorant reads an OpenAI chat file without a column mapping. Each row's messages becomes a conversation, and Tensorant reads each message's role (system, user or assistant) and content. A row is skipped, and listed in the import report, when one of its messages has another field, such as OpenAI's weight or name or an assistant's tool_calls, or when it has a tool message. Fields outside messages, such as tools and parallel_tool_calls, are not read, so a row that defines tools but answers in text imports without the tool definitions. See How rows are recognized.

For example, take a file of 5 OpenAI rows in which one row marks a reply "weight": 0, one row calls a tool, and one row defines tools but answers in text. It imports 3 rows and skips 2: the weight row and the tool-call row.

To keep the rows that only carry weight or name, cut each message down to its role and content:

bash
jq -c '{messages: [.messages[] | {role, content}]}' train.jsonl > train-clean.jsonl
jq -c '{messages: [.messages[] | {role, content}]}' validation.jsonl > validation-clean.jsonl

The same 5 rows, cleaned, import 4 and skip 1. The tool-call row is still skipped, because the assistant message that called the tool has no text and the row keeps its tool message. Tool calling doesn't move to Tensorant, as What doesn't carry over explains.

SFT learns from the assistant replies in each conversation (see Settings every run uses), so after this command a reply you marked "weight": 0 is trained on like the others. If you used weight to keep poor replies out of training, fix or remove those rows before you import.

An OpenAI DPO file imports as it is, with a column mapping: the shared prompt comes from input.messages, the chosen answer from preferred_output and the rejected answer from non_preferred_output. Its input.tools and parallel_tool_calls are not read. A file of 3 OpenAI preference rows imports all 3 with this mapping. Step 4 has the command. See Map columns and Prepare preference pairs.

Tensorant does not accept image URLs in dataset rows. To train on images, use a project with a vision model and import the images from a Hugging Face dataset with an image column. See Shared image prompts and Import images from Hugging Face.

4. Create a project and import the files

Choose an open model from the supported models. Qwen/Qwen3-4B-Instruct-2507, a small instruct model, is one example. If the comparison in step 10 falls short, you can create another project with a larger model and import the same files.

bash
tensorant projects create support-router --model Qwen/Qwen3-4B-Instruct-2507
tensorant projects use PROJECT_ID

The CLI checks the model before it creates the project. Replace PROJECT_ID with the ID it returns; projects use saves it as the default for the next commands.

Import the training file, then the validation file as held-out test data:

bash
tensorant sources import ./train-clean.jsonl --project PROJECT_ID --approve
tensorant sources import ./validation-clean.jsonl --project PROJECT_ID --purpose evaluation --approve

--approve approves the examples that pass Tensorant's quality checks and leaves flagged ones pending for step 5. --purpose evaluation puts the validation file's examples in the test split of every version, never in training. See Training or evaluation.

For an OpenAI DPO file, pass the mapping:

bash
tensorant sources import ./dpo.jsonl --project PROJECT_ID --approve \
  --mapping-json '{"mode": "preference", "prompt": "input.messages", "chosen": "preferred_output", "rejected": "non_preferred_output"}'

Each import reports the examples it added, duplicates, warnings and problems, such as rows skipped with "A message has fields other than role and content". A file can be up to 25 MB and 50,000 rows, and no more than your organization's rows per import, so split a larger file and import the parts. See Sources and review and How imports count.

5. Review and freeze a version

List the examples that wait for review, then approve or reject them:

bash
tensorant examples list --status pending
tensorant examples approve EXAMPLE_ID_1 EXAMPLE_ID_2
tensorant examples reject EXAMPLE_ID_3

An example is pending when a quality check flagged it: a possible email address or phone number, an empty or very short answer, content over 20,000 characters, repeated sentences, or a different answer to the same question, already approved or in the same import. Approval takes up to 500 IDs per request. In the console, Approve all matching on Review's Pending tab approves every example the filters match. See Approve every matching example.

Freeze the approved examples into a version:

bash
tensorant versions create --wait
tensorant versions list

A version is a fixed copy of the approved examples, split into training, validation and test. Your validation file's examples are in its test split. Note the version ID for the next steps. See Versions.

6. Score your current fine-tune while it still answers

Tensorant can send a version's test examples to any endpoint that answers OpenAI-compatible chat completions, OpenAI's own API included. An owner adds your fine-tune as a model endpoint: choose your name at the foot of the sidebar, then Settings, Connections, and Add endpoint under Model endpoints.

Field Value
Name openai-ft
Base address https://api.openai.com/v1
Model Your fine-tune's ID from step 1, starting with ft:
API key Your OpenAI API key

Save openai-baseline.yaml:

yaml
dataset_id: VERSION_ID
endpoint: openai-ft
primary_metric: exact_match
max_tokens: 256
bash
tensorant evaluations start --config openai-baseline.yaml --preview
tensorant evaluations start --config openai-baseline.yaml --yes --wait

For each test example, the model receives the conversation without its last answer, and that answer is the reference. exact_match counts answers that match the reference, ignoring case and spacing, which suits labels and short fixed answers. For free text, token_f1 gives partial credit for shared words. See Presets and metrics. Use the same primary_metric and max_tokens in every evaluation config in this guide.

Each test example is one request to your fine-tune, and OpenAI bills these requests. Tensorant records the result as a baseline evaluation; you compare against it in step 10. Run it before January 14, 2027. After that date your fine-tune no longer answers, and there is nothing left to compare against. See Your own endpoints and Configuration files.

7. Score the open base model

A full training run needs a completed baseline on the same version. Score the open base model for it, on a test session. Save base-deployment.yaml:

yaml
project_id: PROJECT_ID
gpu: NVIDIA L4
gpu_count: 1
max_hours: 0.5
idle_minutes: 5
max_hourly_price: 3
context_length: 4096
bash
tensorant deployments start --config base-deployment.yaml --preview
tensorant deployments start --config base-deployment.yaml
tensorant deployments list

Without run_id, the deployment serves the project's base model. The second command shows the price and asks before it starts the GPU. Set max_hours long enough for the whole evaluation, because the deployment stops at that limit even while it is being scored.

When deployments list shows the deployment ready, save base-model-baseline.yaml. It has the same primary_metric and max_tokens as step 6, and evaluations always run at temperature 0, so the two scores are like for like:

yaml
dataset_id: VERSION_ID
endpoint: managed:DEPLOYMENT_ID
primary_metric: exact_match
max_tokens: 256
bash
tensorant evaluations start --config base-model-baseline.yaml --yes --wait
tensorant deployments stop DEPLOYMENT_ID

A test session is charged while it runs, so stop it once the evaluation completes. See Serving and published models.

An experiment runs this baseline, the full training run and the tuned model's evaluation in one go, and stops its GPUs when it ends. If you run one, compare its tuned evaluation with the OpenAI evaluation as step 10 shows.

8. Run a trial

A trial trains for a few steps on a small sample of the version. It checks the chat formatting, GPU memory and speed, and estimates the full run's time and cost before you pay for full training. Save trial.yaml:

yaml
project_id: PROJECT_ID
dataset_id: VERSION_ID
gpu: NVIDIA L4
gpu_count: 1
provider: tensorant
kind: trial
objective: sft
method: lora
epochs: 2
learning_rate: 0.0002
rank: 32
alpha: 64
context_length: 2048
batch_size: 1
gradient_accumulation: 4
max_hours: 1
max_hourly_price: 3

tensorant training gpus --provider tensorant --purpose training lists the GPUs you can use and their prices. For DPO data, set objective: dpo and delete the learning_rate line, so the run uses DPO's default of 0.0000005.

bash
tensorant training start --config trial.yaml --preview
tensorant training start --config trial.yaml
tensorant runs watch RUN_ID

--preview checks readiness and prices without starting anything. The second command shows a new preview and asks before it spends. When the trial succeeds, its page in the console shows Full training time and Full GPU cost for the full run, at the trial's GPU price. See Try a small trial first.

9. Train the full run

Copy trial.yaml to full.yaml and change it in three places:

  • Replace kind: trial with kind: full.
  • Add baseline_id: BASELINE_ID, the ID of the base model's baseline from step 7.
  • Raise max_hours to cover the trial's Full training time. A run on Tensorant compute lasts at most 24 hours.
bash
tensorant training start --config full.yaml --preview
tensorant training start --config full.yaml
tensorant runs watch RUN_ID --timeout 14400

Use the open model's baseline from step 7, not the OpenAI one. A run trained against a baseline scored on a deployment uses that baseline's model revision, and its adapter is deployed with the same context length and serving settings, so the base model and the adapter are scored the same way. See Deployments and Configuration files.

10. Compare the open model with your OpenAI fine-tune

When the run's adapter is ready, deploy it. Copy base-deployment.yaml to tuned-deployment.yaml and add run_id: RUN_ID. Once deployments list shows it ready, score the adapter with a tuned.yaml that holds only the run:

yaml
run_id: RUN_ID
bash
tensorant deployments start --config tuned-deployment.yaml
tensorant deployments list
tensorant evaluations start --config tuned.yaml --yes --wait

The tuned evaluation uses the run's ready deployment and is scored the way its baseline was, on the same test examples. Compare it with the OpenAI evaluation from step 6, list the answers that got worse, and stop the deployment:

bash
tensorant evaluations list
tensorant evaluations compare OPENAI_EVALUATION_ID TUNED_EVALUATION_ID
tensorant evaluations compare OPENAI_EVALUATION_ID TUNED_EVALUATION_ID --outcome regressed
tensorant deployments stop DEPLOYMENT_ID

To see what training added, compare the base model's baseline with the tuned evaluation the same way.

In the console, open the tuned evaluation and choose the OpenAI evaluation under Compare with. The change shown is the opened evaluation's score minus the other's, with a likely range and the answers that improved and regressed.

A clear improvement has a positive change, a likely range entirely above zero, and few regressed answers. A range that crosses zero means the test set can't tell the two models apart. Add test examples from more documents to narrow it. Read the regressed answers even when the average improves, because a good average can hide a new mistake that matters to your application. See Compare any two evaluations and Read a comparison.

11. Publish the model and change your base URL

An owner publishes the adapter as an API model, in the console under Models with Create API model, or with the CLI and an owner's Full sign-in. Save published-model.yaml:

yaml
project_id: PROJECT_ID
name: support
run_id: RUN_ID
mode: always
gpu: NVIDIA L4
gpu_count: 1
days: 1
max_hourly_price: 3
context_length: 4096
bash
tensorant models publish --config published-model.yaml --preview
tensorant models publish --config published-model.yaml

mode: always keeps a GPU running for the days you set. For occasional traffic, mode: wake starts the model when a request arrives and stops it after its warm time. It takes a different GPU setting and no days, as the command reference shows. See API models to choose between them.

An owner then creates an API key under API keys in the console. Store it with your application's secrets as TENSORANT_API_KEY. In your code, change the client and the model name:

python
import os

from openai import OpenAI

# Before: client = OpenAI() and model="ft:...", your fine-tune's ID
client = OpenAI(base_url="https://api.tensorant.io/v1", api_key=os.environ["TENSORANT_API_KEY"])

answer = client.chat.completions.create(
    model="support",
    messages=[{"role": "user", "content": "Where is my order?"}],
)
print(answer.choices[0].message.content)

model is the name you published, here support. With mode: wake, the first request after a quiet period can wait up to a minute while the model starts, or get 503 model_starting with a Retry-After header. See the API quickstart and Cold starts and retries.

What doesn't carry over

The chat completions reference lists every field the API takes. These differences affect an application that moves from OpenAI.

  • The API serves chat completions only, on POST /v1/chat/completions, and lists models on GET /v1/models. Other routes, OpenAI's Responses API among them, answer 404 not_found.
  • Any field the reference doesn't list, such as OpenAI's tools, store or metadata, is refused with 400 unsupported_parameter, even when it is null. See Fields that are refused.
  • A message with a name field, or with the developer or tool role, is refused with 400 invalid_request. See Messages.
  • A fine-tune trained to call tools can't be moved as a tool-calling model. Its tool-call rows are skipped at import (step 3), and the API refuses tools.
  • When a request leaves them out, temperature is 0 and max_tokens is 512. n must be 1.
  • OpenAI's fine-tuned weights are not part of the move. You train new weights, a LoRA adapter for an open model, on the same data. You can download that adapter with tensorant runs download RUN_ID --output ./adapter.zip.

The OpenAI fine-tuning migration overview covers the whole timeline. For where Tensorant keeps your data and what can stay in your own cloud, see Fine-tune LLMs on private and sensitive data.