Extract API

The extract endpoints (POST /workspaces/{slug}/schemas/{schemaKey}/extract and .../documents/{id}/extract) accept an optional model body field that overrides the environment’s provider/model assignment for a single run. Useful for A/B testing, fallback fan-out, or one-off premium runs.

For the full request/response schema, see the API reference: Extract Document and Extract from Document.

model body field

{
  "documentId": "doc_abc123",
  "model": "anthropic/claude-opus-4-7"
}

Format is <provider>/<model>. Both halves are required, separated by a single forward slash.

  • <provider> — one of mistral, anthropic, openai, google.
  • <model> — must be in that provider’s allowlist (see Choosing a model for the full list).

Precedence

request.model  >  env.providerKeyId + env.model  >  system fallback (Mistral)
  1. Request override (this page) — highest priority. The named provider must either have a user key OR be Mistral (in which case the system Mistral key is used).
  2. Environment assignment — set on the env via PATCH /workspaces/{slug}/environments/{envSlug}. See Environments.
  3. System fallback — if neither is configured, runs use Tracore’s system Mistral key (pixtral-large-latest, EU residency).

Errors

HTTPCodeCause
400invalid_modelModel not in provider’s allowlist, or model doesn’t match <provider>/<model>.
400invalid_providerProvider segment isn’t one of mistral/anthropic/openai/google.
412no_keyRequest names a non-Mistral provider, but the user has no key for that provider.

SDK usage

import { TracoreClient } from "@tracore/sdk";

const client = new TracoreClient({ apiKey: process.env.TRACORE_API_KEY! });

// One-off premium run on top of the env's default provider
const run = await client.extract(
  "my-workspace",
  "invoice",
  { documentId: "doc_abc123" },
  {
    model: "anthropic/claude-opus-4-7",
    poll: true,
  }
);

The same model option works on both inline-upload ({ file, name }) and existing-document ({ documentId }) variants of client.extract.

Run record

Whatever resolves wins is snapshotted on the run row at enqueue time:

{
  "id": "run_…",
  "status": "completed",
  "provider": "anthropic",
  "model": "claude-opus-4-7",
  "keySource": "user",
  "inputTokens": 1240,
  "outputTokens": 312,
  "totalTokens": 1552
}

keySource is "user" when the run consumed a stored provider key, "system" for the Mistral fallback. Token counts are populated when the provider returns usage; they’re null while the run is still pending or for older runs that predate the BYOK rollout.