---
title: "Mint a model lease for MCPJam-hosted inference"
method: POST
path: "/projects/{projectId}/model-leases"
tags: ["Eval runs"]
---

# Mint a model lease for MCPJam-hosted inference

`POST /projects/{projectId}/model-leases`

How an SDK eval running OUTSIDE the platform (local dev, CI) uses MCPJam-hosted inference on the organization's credits, with no provider key of its own. Authenticate like any other `/api/v1` route (typically an `sk_` key).

The lease is strictly narrower than the key used to get it: one organization, one project, one model, one proxy host, about 30 minutes, a per-lease spend and call cap, and revocable by `runId`.

The `{projectId}` segment declares which project's organization pays, and always wins over any `projectId` in the body. The literal `default` resolves to the key org's Default project — the zero-config CI case, and the same resolution the eval-ingest routes use, so a lease and the results it produces land in the same project.

## Path parameters

- `projectId` string, required

## Request body

- ModelLeaseRequest
  - `model` string, required — Canonical model id. Only `anthropic/claude-*` and `openai/gpt-5*` are served, and only if the model has a gateway pricing row.
  - `runId` string — Caller-chosen id to revoke by. Generated if omitted.
  - `maxOutputTokens` integer — Per-call output ceiling, clamped to the server maximum.

## Response `200`

A short-lived lease and the proxy to present it to.

- ModelLease
  - `lease` string, required — Present it as the `x-mcpjam-harness-lease` header on requests to `proxyBaseUrl`. Never as a bearer token, and never sent to any other host.
  - `protocol` 'anthropic' | 'openai', required — Which vendor wire format `proxyBaseUrl` speaks, derived from the model's vendor prefix.
  - `proxyBaseUrl` string, uri, required — Base URL for the metered model proxy. Anthropic leases accept `POST /v1/messages`; OpenAI leases accept `POST /v1/responses`.
  - `expiresAt` integer, required — Epoch milliseconds. Mint a new lease before this; the proxy fails an expired one closed.
  - `runId` string, required — Pass to the revoke operation to kill this lease early.
  - `model` string, required

## Other responses

- `400` — Malformed body or parameters.
- `401` — Missing, invalid, revoked, or orphaned key (`UNAUTHORIZED`) — or the **target MCP server** needs an OAuth grant (`OAUTH_REQUIRED`), which is a property of the server, not your key.
- `403` — Key is valid but not allowed to do this.
- `404` — Unknown project, server, or resource.
- `429` — Per-key rate limit exceeded (60 requests/minute sustained, bursts up to 10). Honor `Retry-After` and back off with jitter.
- `500` — Something failed on MCPJam's side.
- `502` — Could not connect to the target MCP server.
- `504` — The target MCP server connected but didn't respond in time.

## Changes

- **2026-09-16** `49fb945e71f0` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/mcpjam/apis/mcpjam-api/changes/projects/:projectId/model-leases/post.md)

---

[API](https://skmtc.dev/mcpjam/apis/mcpjam-api.md) · [All operations](https://skmtc.dev/mcpjam/apis/mcpjam-api/llms.txt) · [OpenAPI document](https://skmtc.dev/mcpjam/apis/mcpjam-api/revisions/04044ef64a5f?raw)
