Let your agents run the dojo.
Everything you can do in Kojen — projects, templates, datasets, Forge training runs, model versions, evaluations, simulations, deployments, autonomous agents, orchestration, the marketplace, workspaces, katas and Sensei — is available over a REST API and an MCP server. Both act as the API key's owner, with the same row-level permissions as the web app. The server is listed in the official MCP Registry as ai.kojen/kojen.
Create an API key
Go to Settings → API Keys & MCP and create a key. Send it as Authorization: Bearer kojen_… (or x-api-key). Keys are shown once and stored only as a hash; revoke them any time.
Connect an MCP client
Streamable HTTP endpoint: /api/mcp. Claude Code:
claude mcp add --transport http kojen https://kojen.ai/api/mcp \ --header "Authorization: Bearer kojen_…"
Other clients (Claude Desktop, Cursor, …):
{
"mcpServers": {
"kojen": {
"type": "http",
"url": "https://kojen.ai/api/mcp",
"headers": { "Authorization": "Bearer kojen_…" }
}
}
}Call the API
Base URL /api/v1. Responses are { data } or { error: { status, message } }. Full spec: /api/v1/openapi.json.
# Create a key under Settings → API Keys & MCP, then:
export KOJEN_KEY=kojen_…
# What's in my dojo?
curl -H "Authorization: Bearer $KOJEN_KEY" https://kojen.ai/api/v1/summary
# Create a project, give it a test set, and tune a prompt for it (runs for real)
curl -X POST -H "Authorization: Bearer $KOJEN_KEY" -H "Content-Type: application/json" \
-d '{"name":"Support triage","description":"Route support tickets to billing, bug or how-to","model_type":"classification"}' \
https://kojen.ai/api/v1/projects
curl -X POST -H "Authorization: Bearer $KOJEN_KEY" -H "Content-Type: application/json" \
-d '{"name":"triage-cases","project_id":"<id>","rows":[{"input":"I was charged twice","expected":"billing"},{"input":"App crashes on login","expected":"bug"}]}' \
https://kojen.ai/api/v1/datasets/import
curl -X POST -H "Authorization: Bearer $KOJEN_KEY" -H "Content-Type: application/json" \
-d '{"name":"triage-prompt","pipeline_type":"prompt_tuning","project_id":"<id>","dataset_id":"<dataset-id>","base_model":"llama-3.1-8b"}' \
https://kojen.ai/api/v1/tools/train_model
# Poll it
curl -H "Authorization: Bearer $KOJEN_KEY" https://kojen.ai/api/v1/training-pipelines/<run-id>GET /api/v1/{resource}List (filters as query params, limit, offset, order=created_at.desc)POST /api/v1/{resource}Create; ownership is set to the key's ownerGET | PATCH | DELETE /api/v1/{resource}/{id}Read, update, delete one recordPOST /api/v1/datasets/importCreate a dataset from inline rows or CSV textPOST /api/v1/datasets/{id}/profileRow count, columns, preview, test-set fitPOST /api/v1/templates/{id}/useStart a project from a template (with starter data)POST /api/v1/training-pipelines/{id}/startStart a training runPOST /api/v1/model-versions/{id}/activateMake a version its project's active modelPOST /api/v1/evaluations/{id}/runRun an evaluation (trust score + results)POST /api/v1/simulations/{id}/runRun a simulationPOST /api/v1/deployments/{id}/deploy | start | stopRoll out or toggle an endpointPOST /api/v1/agent-tasks/dispatchCreate and launch an autonomous agentPOST /api/v1/agent-tasks/{id}/launch | cancelControl an agent taskPOST /api/v1/agent-pipelines/{id}/runRun a multi-agent pipelinePOST /api/v1/katas/{id}/start | completeWork through katas ({submission} is graded by Sensei)POST /api/v1/endpoints/{deployment}/chat/completionsCall a deployed model (OpenAI-compatible)POST /api/v1/endpoints/{deployment}/feedbackRate a prediction to drive continuous learningPOST /api/v1/senseiAsk Sensei ({question} or {messages}, mode)POST /api/v1/agentLet the Kojen Agent do it for youGET /api/v1/tools · POST /api/v1/tools/{name}Every MCP tool, over RESTGET /api/v1/modelsModel catalog keys for training, evals and deploymentsPOST /api/v1/tools/get_gpu_credits | buy_gpu_creditsGPU credit balance, or a checkout link to top upPOST /api/v1/tools/get_audio_samplesBase vs tuned clips from an audio_lora runGET /api/v1/summary · GET /api/v1/meWorkspace counts, caller profileResources: projects, datasets, training-pipelines, evaluations, simulations, synthetic-datasets, model-versions, deployments, deployment-metrics, feedback, agent-tasks, agent-pipelines, conversations, messages, katas, kata-progress, templates, marketplace, workspaces, workspace-members, comments, preferences, profiles.
Runs (training, evaluations, simulations, agent tasks and pipelines) execute server-side against real models and take from seconds to a few minutes. Poll the record, or use the wait_for_run tool. Prompt tuning and model search (automl) train for real and save a model version. LoRA, full fine-tuning and RLHF for text models are previews with simulated metrics.
audio_lora trains a real adapter on ACE-Step 1.5 on GPUs from a ZIP of at least four audio files (each with an optional name.caption.txt), uploaded on the Datasets page. It's limited to accounts with GPU training enabled, and runs take minutes to hours. A run reserves GPU credits up front and is charged only for the GPU time it used: check get_gpu_credits first, and buy_gpu_credits returns a checkout link for a person to pay. When it finishes, get_audio_samples returns the base and tuned clips.
A deployed model is an OpenAI-compatible endpoint: point any OpenAI client at https://kojen.ai/api/v1/endpoints/<deployment id> with your Kojen key. Each completion carries kojen.prediction_id; send it to /feedback to feed auto-retraining.
35 agent tools
The same tools power the MCP server, POST /api/v1/tools/{name}, and the in-app Kojen Agent.
get_workspace_summaryCounts of the caller's projects, datasets, training runs, evaluations, simulations, deployments, agent tasks and completed katas.
describe_resourcesList every Kojen resource type with its description, filterable columns and allowed values. Call this first to learn the data model.
list_modelsList the model catalog keys accepted wherever a tool takes a model (base_model, model, models): training, evaluations, simulations and deployments. Models are served through the Vercel AI Gateway.
list_recordsList records of a resource (see describe_resources), newest first. Supports equality filters on the resource's filter columns.
get_recordFetch one record of a resource by id. Run-type records (training, evaluations, simulations, deployments, agent tasks/pipelines) are returned with up-to-date progress.
create_recordCreate a record of any resource. Ownership is set to the caller automatically; server-managed fields are ignored.
update_recordUpdate fields on a record. Server-managed fields (status, progress, results, …) are ignored; use the run tools instead.
delete_recordPermanently delete a record. Confirm with the user before deleting anything they did not ask to delete.
create_projectCreate an ML project.
use_templateStart a project from a use-case template (list_records resource=templates), like 'Use template' in the web app: creates the project and runs a real synthetic_data simulation that writes a starter dataset with the template's columns. Returns {project, simulation}; wait_for_run on the simulation for the dataset.
activate_model_versionMake a model version its project's active version (the previous active one is archived). Deployments and agents with no explicit model use the active version.
create_datasetCreate a dataset from inline data — `rows` (array of objects) or `csv` (text with a header row), up to 5000 rows — stored as CSV. Use columns named input/expected (or prompt/answer, question/label, …) to make it usable as a test set for training and evaluations. Larger files are uploaded in the web app.
profile_datasetRead a dataset's file and report its real row count, columns, a 5-row preview and whether it works as a test set (which columns are read as input/expected). save=true (default) records the counts and status on the dataset.
train_modelCreate a training run and start it. REAL methods: prompt_tuning (optimises a system prompt for the project's task on base_model over several judge-scored rounds) and automl (model search: scores the task on 3-5 catalog models and picks the best by accuracy, latency as tie-break). Both use the dataset's input/expected rows or generated test cases, hold out 30% for a final check, and on completion save an active model version to the project (project_id needed for that). GPU method: audio_lora trains a real LoRA adapter on ACE-Step 1.5 from a dataset that is a ZIP of at least 4 audio files, each with an optional <name>.caption.txt (upload it on the web app's Datasets page; the API can't upload files). It needs rights_confirmed=true, is limited to accounts with GPU training enabled (one run at a time), reserves GPU credits up front and charges only the GPU time used (check get_gpu_credits first), runs for minutes to hours, and saves a draft model version that can't be activated or used for text evaluations/deployments; get_audio_samples returns its base vs tuned clips. PREVIEW methods: lora, finetune, rlhf for text models — simulated, no weights are trained yet (metrics.simulated=true). Poll with wait_for_run; results land in metrics.
start_training_run(Re)start an existing training run. prompt_tuning/automl run for real and save a new model version; audio_lora trains on GPUs and reserves GPU credits (see train_model); lora/finetune/rlhf are simulated previews.
get_gpu_creditsGPU training (audio_lora) is paid in credits: a run reserves required_per_run credits before it starts and is charged only for the GPU time it used. Returns the balance, the reservation, whether that's enough, and whether GPU training is enabled for this account.
buy_gpu_creditsCreate a hosted checkout link for GPU credits (default: the shortfall for one run). Nothing is charged by this call: give the URL to the human to open and pay.
get_audio_samplesFor a finished audio_lora training run, return its generated clips (the same prompt rendered by the base and the tuned model) with download URLs valid for 15 minutes.
evaluate_modelCreate and run a real evaluation: the target model answers test cases (from a dataset, or generated from the project's task) and an LLM judge grades every answer. accuracy = correct vs expected, hallucination = fabricated/unsupported claims, bias = paired prompts differing only in a demographic attribute, custom = your criteria rubric, comprehensive = accuracy + hallucination + bias. Latency (p50/p95/p99) is measured on real calls. Results include per-case verdicts and a 0-100 trust score (comprehensive: accuracy 50%, hallucination 30%, bias 20%). Follow with wait_for_run.
run_evaluation(Re)run an existing evaluation for real against its configured target and test set. Follow with wait_for_run.
run_simulationCreate and run a real simulation against a model. synthetic_data: the judge model writes rows for your columns and saves them as a new dataset. adversarial: generates attack prompts, runs them on the target and grades which succeeded (robustness_score = % defended). stress_test: fires real concurrent requests and measures latency percentiles, error rate and throughput. scenario: runs given or generated scenarios on the target and grades pass/fail. Runs in the background — use wait_for_run.
deploy_modelCreate a deployment and deploy it. Serves a model version (model_version_id) or a base model + system prompt (model, system_prompt); without either, the project's active model version. A real smoke-test call validates it: on success status is active and endpoint_url is a live OpenAI-compatible chat completions URL (auth: Authorization: Bearer kojen_… API key of this account); on failure status is failed with config.last_error.
set_deployment_runningStart (running=true) or stop (running=false) a deployment endpoint. Stopped endpoints reject requests with 409; starting a never-deployed or failed one redeploys it.
dispatch_agentDispatch a real autonomous agent task; it works step by step, writing a live log (logs) and its findings (output_result). data_cleaner profiles a dataset (nulls, duplicates, whitespace/casing, bad numbers), cleans it deterministically, saves '<name> (cleaned)' as a new dataset and adds judge recommendations. researcher recommends an approach and catalog models, then benchmarks 2-3 models on 3 generated cases (measured accuracy/latency). trainer runs a real prompt-tuning training run and reports its metrics and model version. evaluator runs a comprehensive evaluation and reports the trust score. deployer deploys to staging and reports the endpoint_url. Returns the running task; follow it with wait_for_run.
cancel_agent_taskCancel a queued or running agent task (child runs it already started keep their own status).
orchestrate_agentsCreate a real multi-agent pipeline (ordered steps) and optionally run it, e.g. clean → train → evaluate → deploy. Each step runs as an agent task in the pipeline's project; outputs flow forward (cleaned dataset → trainer, recommended model → trainer, trained model version → evaluator/deployer). A failed step fails the pipeline; results hold per-step summaries, task ids and total duration.
run_agent_pipeline(Re)run an existing orchestrator pipeline from its first step (resets step statuses).
import_marketplace_listingCopy a published marketplace listing's model (base model + system prompt) into one of your projects as a new draft model version. Evaluate it, then activate_model_version.
rate_marketplace_listingRate a published marketplace listing 1-5 stars (one rating per user; rating again replaces it). Returns the new average.
invite_to_workspaceAdd an existing Kojen user to a workspace by email. Only workspace owners and admins can invite.
list_katasList training katas with the caller's progress on each.
start_kataStart (or retry) a kata. Read its instructions and expected_output, do the work, then call complete_kata.
complete_kataSubmit a kata attempt. Pass your `submission` (the work, as text) to have it graded 0-100 by an LLM judge against the brief, or a `score` you measured yourself. 70+ completes the kata; the best score is kept.
wait_for_runWait until a training run, evaluation, simulation, deployment, agent task or agent pipeline finishes (or the timeout passes), then return it.
ask_senseiAsk Sensei, Kojen's AI training guide, for advice. mode=intent_to_model turns a problem description into a full plan (dataset schema, model, eval, deployment).
Or just ask the Kojen Agent
POST /api/v1/agent with {"question": "Train and evaluate a sentiment model, then deploy it to staging"} and the Kojen Agent chains the tools for you.