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.

Authenticate

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.

MCP

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_…" }
    }
  }
}
REST API

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 owner
GET | PATCH | DELETE /api/v1/{resource}/{id}Read, update, delete one record
POST /api/v1/datasets/importCreate a dataset from inline rows or CSV text
POST /api/v1/datasets/{id}/profileRow count, columns, preview, test-set fit
POST /api/v1/templates/{id}/useStart a project from a template (with starter data)
POST /api/v1/training-pipelines/{id}/startStart a training run
POST /api/v1/model-versions/{id}/activateMake a version its project's active model
POST /api/v1/evaluations/{id}/runRun an evaluation (trust score + results)
POST /api/v1/simulations/{id}/runRun a simulation
POST /api/v1/deployments/{id}/deploy | start | stopRoll out or toggle an endpoint
POST /api/v1/agent-tasks/dispatchCreate and launch an autonomous agent
POST /api/v1/agent-tasks/{id}/launch | cancelControl an agent task
POST /api/v1/agent-pipelines/{id}/runRun a multi-agent pipeline
POST /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 learning
POST /api/v1/senseiAsk Sensei ({question} or {messages}, mode)
POST /api/v1/agentLet the Kojen Agent do it for you
GET /api/v1/tools · POST /api/v1/tools/{name}Every MCP tool, over REST
GET /api/v1/modelsModel catalog keys for training, evals and deployments
POST /api/v1/tools/get_gpu_credits | buy_gpu_creditsGPU credit balance, or a checkout link to top up
POST /api/v1/tools/get_audio_samplesBase vs tuned clips from an audio_lora run
GET /api/v1/summary · GET /api/v1/meWorkspace counts, caller profile

Resources: 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.

Tools

35 agent tools

The same tools power the MCP server, POST /api/v1/tools/{name}, and the in-app Kojen Agent.

get_workspace_summaryreads

Counts of the caller's projects, datasets, training runs, evaluations, simulations, deployments, agent tasks and completed katas.

describe_resourcesreads

List every Kojen resource type with its description, filterable columns and allowed values. Call this first to learn the data model.

list_modelsreads

List 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_recordsreads

List records of a resource (see describe_resources), newest first. Supports equality filters on the resource's filter columns.

get_recordreads

Fetch 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_recordwrites

Create a record of any resource. Ownership is set to the caller automatically; server-managed fields are ignored.

update_recordwrites

Update fields on a record. Server-managed fields (status, progress, results, …) are ignored; use the run tools instead.

delete_recordwrites

Permanently delete a record. Confirm with the user before deleting anything they did not ask to delete.

create_projectwrites

Create an ML project.

use_templatewrites

Start 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_versionwrites

Make 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_datasetwrites

Create 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_datasetreads

Read 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_modelwrites

Create 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_runwrites

(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_creditsreads

GPU 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_creditswrites

Create 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_samplesreads

For 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_modelwrites

Create 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_evaluationwrites

(Re)run an existing evaluation for real against its configured target and test set. Follow with wait_for_run.

run_simulationwrites

Create 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_modelwrites

Create 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_runningwrites

Start (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_agentwrites

Dispatch 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_taskwrites

Cancel a queued or running agent task (child runs it already started keep their own status).

orchestrate_agentswrites

Create 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_pipelinewrites

(Re)run an existing orchestrator pipeline from its first step (resets step statuses).

import_marketplace_listingwrites

Copy 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_listingwrites

Rate a published marketplace listing 1-5 stars (one rating per user; rating again replaces it). Returns the new average.

invite_to_workspacewrites

Add an existing Kojen user to a workspace by email. Only workspace owners and admins can invite.

list_katasreads

List training katas with the caller's progress on each.

start_katawrites

Start (or retry) a kata. Read its instructions and expected_output, do the work, then call complete_kata.

complete_katawrites

Submit 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_runreads

Wait until a training run, evaluation, simulation, deployment, agent task or agent pipeline finishes (or the timeout passes), then return it.

ask_senseireads

Ask 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).

Delegate

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.