Resolve the model behind a request

Turn a display name into the exact deployment identity your logs, billing pipeline, and incident tooling can rely on.

What you will build

A resolver that starts with a canonical model ID and returns a provider-specific record suitable for request metadata. The resulting identity remains explicit even when two providers expose the same model release.

canonical identity
model_id tells you what model release was requested.
runtime identity
deployment_id, provider_id, provider_model_id, region, and api_surface tell you what can actually serve it.
decision evidence
capabilities, lifecycle, rate_card, and the catalog release explain why it was eligible.

1. Resolve the canonical model

TypeScript
import { ALLM } from "@allm/sdk";

const allm = new ALLM({ apiKey: process.env.ALLM_API_KEY });
const model = await allm.models.retrieve("anthropic/claude-haiku-4.5");

console.log(model.id);         // anthropic/claude-haiku-4.5
console.log(model.family);     // anthropic/claude-haiku
console.log(model.modalities); // ["image", "pdf", "text"]

2. Select a concrete deployment

Query deployments using hard integration requirements. Apply additional checks locally because one query parameter expresses only one capability at a time.

TypeScript
const result = await allm.deployments.list({
  model: model.id,
  region: "global",
  capability: "tool_calling",
  lifecycle_status: "available",
  has_pricing: true,
});

const deployment = result.data.find((candidate) =>
  candidate.capabilities.structured_output?.status === "supported" &&
  candidate.context_tokens !== null &&
  candidate.context_tokens >= 128_000
);

if (!deployment) {
  throw new Error("NO_ELIGIBLE_DEPLOYMENT");
}

3. Record identity with the generation

Store the ALLM deployment ID beside the gateway’s request and response IDs. Do not infer it later from a model alias: aliases and routing configuration can change.

TypeScript
const generationIdentity = {
  generationId: crypto.randomUUID(),
  requestedModel: model.id,
  deploymentId: deployment.id,
  providerId: deployment.provider_id,
  providerModelId: deployment.provider_model_id,
  apiSurface: deployment.api_surface,
  region: deployment.region,
  lifecycleStatus: deployment.lifecycle.status,
  rateObservedAt: deployment.rate_card?.observed_at ?? null,
};

await generationLog.insert(generationIdentity);

Example output

JSON
{
  "generationId": "gen_01K0C2TQ6J7S8A9B0D4E5F6G7H",
  "requestedModel": "anthropic/claude-haiku-4.5",
  "deploymentId": "dep_anthropic_claude_haiku_4_5_messages_global",
  "providerId": "anthropic",
  "providerModelId": "claude-haiku-4-5-20251001",
  "apiSurface": "messages",
  "region": "global",
  "lifecycleStatus": "available",
  "rateObservedAt": "2026-07-14T00:00:00Z"
}

Failure modes

  • No deployment: distinguish “model not found” from “model exists but no candidate satisfies the policy.”
  • Unknown limits: a null context window is not unlimited.
  • Conditional capability: inspect and enforce its conditions before selecting it.
  • Alias drift: always log provider_model_id returned for the chosen deployment.