@meterapp/car-image-sdk 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp/index.js CHANGED
@@ -10,8 +10,11 @@
10
10
  * entry point of the SDK has no runtime dependencies.
11
11
  */
12
12
  import * as z from "zod";
13
- import { CATALOG, COLORS, CREDITS_PER_DOLLAR, CREDITS_PER_IMAGE, DEFAULT_BASE_URL, FITS, FORMATS, FREE_CREDITS, MAX_DIMENSION, MAX_PADDING_PERCENT, MIN_YEAR, REFERRAL_SOURCES, REQUEST_KINDS, REQUEST_SORTS, REQUEST_STATUSES, SIZES, VIEWS, } from "../types.js";
13
+ import { isColor } from "../params.js";
14
+ import { CATALOG, COLORS, CREDITS_PER_3D_MODEL, CREDITS_PER_DOLLAR, CREDITS_PER_IMAGE, DEFAULT_BASE_URL, FITS, FORMATS, FREE_CREDITS, IDEMPOTENCY_KEY_PATTERN, MAX_DIMENSION, MAX_PADDING_PERCENT, MIN_YEAR, MODEL_3D_FILE_KINDS, REFERRAL_SOURCES, REQUEST_FORMATS, REQUEST_KINDS, REQUEST_SORTS, REQUEST_STATUSES, SIZES, VEHICLE_ID_PATTERN, VIEWS, } from "../types.js";
14
15
  import { SDK_VERSION } from "../version.js";
16
+ /** The 3D price as agents read it: "1,000 credits ($1.00)". */
17
+ const MODEL_3D_PRICE = `${CREDITS_PER_3D_MODEL.toLocaleString("en-US")} credits ($${(CREDITS_PER_3D_MODEL / CREDITS_PER_DOLLAR).toFixed(2)})`;
15
18
  /**
16
19
  * Catalog size as agents read it in the instructions and tool descriptions.
17
20
  * Derived from CATALOG so the figures cannot drift from the database; agents
@@ -39,9 +42,12 @@ export const MCP_TOOLSETS = {
39
42
  "create_car_image_urls",
40
43
  "search_vehicles",
41
44
  "resolve_vehicle",
45
+ "decode_vin",
42
46
  "list_image_options",
43
47
  "get_account",
44
48
  "rate_image",
49
+ "create_3d_model",
50
+ "get_3d_model",
45
51
  "describe_api",
46
52
  ],
47
53
  all: [
@@ -49,9 +55,12 @@ export const MCP_TOOLSETS = {
49
55
  "create_car_image_urls",
50
56
  "search_vehicles",
51
57
  "resolve_vehicle",
58
+ "decode_vin",
52
59
  "list_image_options",
53
60
  "get_account",
54
61
  "rate_image",
62
+ "create_3d_model",
63
+ "get_3d_model",
55
64
  "describe_api",
56
65
  "list_requests",
57
66
  "request_vehicle",
@@ -68,11 +77,11 @@ export const MCP_TOOLSET_NAMES = Object.keys(MCP_TOOLSETS);
68
77
  export function isMcpToolset(value) {
69
78
  return typeof value === "string" && MCP_TOOLSET_NAMES.includes(value);
70
79
  }
71
- const INSTRUCTIONS_COMMON = `Car Image API by Meter: studio-quality, transparent-background renders of any vehicle in the open @meterapp/vehicle-db catalog (${CATALOG_MAKES} makes, ${CATALOG_MODELS} models, model years ${CATALOG_YEARS}). Six camera views, fifteen preset colors, PNG/WebP/JPG up to 1024 px, any width and height (fit contain|cover|inside), transparent or a solid background color.
80
+ const INSTRUCTIONS_COMMON = `Car Image API by Meter: studio-quality, transparent-background renders of any vehicle in the open @meterapp/vehicle-db catalog (${CATALOG_MAKES} makes, ${CATALOG_MODELS} models, model years ${CATALOG_YEARS}). Six camera views, any paint color (fifteen named presets or any hex such as #1a2b3c), PNG/WebP/JPG up to 1024 px, any width and height (fit contain|cover|inside), transparent or a solid background color. Every catalog vehicle has a stable id (veh_ followed by 13 characters) that search_vehicles, resolve_vehicle and decode_vin return and every image or 3D tool accepts as \`vehicle\` in place of make, model and year.
72
81
 
73
- Costs: every delivered image costs exactly ${CREDITS_PER_IMAGE} credit ($1 = ${CREDITS_PER_DOLLAR.toLocaleString("en-US")} credits; ${FREE_CREDITS} free credits per account), cold or CDN hit. create_car_image_urls charges 1 credit per URL when the URL is created; redemptions are free. search_vehicles, resolve_vehicle, list_image_options, get_account, rate_image and describe_api are free.
82
+ Costs: every delivered image costs exactly ${CREDITS_PER_IMAGE} credit ($1 = ${CREDITS_PER_DOLLAR.toLocaleString("en-US")} credits; ${FREE_CREDITS} free credits per account), cold or CDN hit. create_car_image_urls charges 1 credit per URL when the URL is created; redemptions are free. create_3d_model costs ${MODEL_3D_PRICE} per model, charged when the request is made: confirm with the human before calling it. search_vehicles, resolve_vehicle, decode_vin, list_image_options, get_account, rate_image, get_3d_model and describe_api are free.
74
83
 
75
- Workflow: (1) resolve_vehicle turns free text such as "red 2024 porsche 911 side view" into exact parameters; search_vehicles browses the catalog. (2) Call get_car_image when the image itself is needed in the conversation. (3) For web pages, emails, documents or anything a browser will load, call create_car_image_urls and embed the signed URLs; they need no key.
84
+ Workflow: (1) resolve_vehicle turns free text such as "red 2024 porsche 911 side view" into exact parameters; search_vehicles browses the catalog; decode_vin turns a VIN into the catalog vehicle and its id. (2) Call get_car_image when the image itself is needed in the conversation. (3) For web pages, emails, documents or anything a browser will load, call create_car_image_urls and embed the signed URLs; they need no key. (4) For a textured 3D model (GLB, USDZ, FBX), call create_3d_model once the human has agreed to the cost, then poll get_3d_model every few seconds until status is ready and hand over files.<kind>.url; a model takes one to five minutes.
76
85
 
77
86
  Security: never place the API key in URLs, HTML, logs, screenshots or client-side code. Signed delivery URLs are the only thing that should ever reach a browser.
78
87
 
@@ -92,16 +101,38 @@ const yearSchema = z.coerce
92
101
  .int()
93
102
  .min(MIN_YEAR)
94
103
  .max(2100)
95
- .describe(`Model year, e.g. 2024. The catalog covers ${MIN_YEAR} through next year.`);
96
- export const imageInputSchema = z.object({
97
- make: z.string().min(1).max(80).describe('Manufacturer, e.g. "Porsche", "BMW", "Toyota". Case and punctuation do not matter.'),
98
- model: z.string().min(1).max(80).describe('Model as listed in the catalog, e.g. "911", "M3", "Corolla".'),
99
- year: yearSchema,
104
+ .describe(`Model year, e.g. 2024. The catalog covers ${MIN_YEAR} through next year. Omit when vehicle is given.`);
105
+ /** A paint color: a preset name, or a hex such as `#1a2b3c` (`1a2b3c` and `#rgb` are accepted too). */
106
+ export const colorSchema = z
107
+ .string()
108
+ .min(1)
109
+ .max(20)
110
+ .refine(isColor, { message: `color must be one of ${COLORS.join(", ")}, or a hex like #1a2b3c` })
111
+ .describe(`Paint color: one of the presets (${COLORS.join(", ")}) or a hex like #1a2b3c. Responses echo a hex as #rrggbb.`);
112
+ /** A stable catalog vehicle id, as every catalog tool returns it. */
113
+ export const vehicleIdSchema = z
114
+ .string()
115
+ .regex(VEHICLE_ID_PATTERN, "vehicle must be a vehicle id: veh_ followed by 13 characters")
116
+ .describe("Stable vehicle id such as veh_395yw8tn73ff8 (from search_vehicles, resolve_vehicle or decode_vin). Names the make, model and year, so omit those when it is given.");
117
+ const vehicleFields = {
118
+ vehicle: vehicleIdSchema.optional(),
119
+ make: z.string().min(1).max(80).optional().describe('Manufacturer, e.g. "Porsche", "BMW", "Toyota". Case and punctuation do not matter. Omit when vehicle is given.'),
120
+ model: z.string().min(1).max(80).optional().describe('Model as listed in the catalog, e.g. "911", "M3", "Corolla". Omit when vehicle is given.'),
121
+ year: yearSchema.optional(),
122
+ };
123
+ /** Either the vehicle id or all three of make, model and year; the server rejects both together. */
124
+ function namesOneVehicle(input) {
125
+ return input.vehicle !== undefined || (input.make !== undefined && input.model !== undefined && input.year !== undefined);
126
+ }
127
+ const ONE_VEHICLE = { message: "Give either vehicle (a veh_… id) or all of make, model and year" };
128
+ export const imageInputSchema = z
129
+ .object({
130
+ ...vehicleFields,
100
131
  view: z
101
132
  .enum(VIEWS)
102
133
  .default("front-3-4")
103
134
  .describe("Camera angle: front (0°), front-3-4 (35°, the classic hero angle), side (profile, nose left), side-right (profile, nose right), rear (180°), rear-3-4 (145°)."),
104
- color: z.enum(COLORS).default("silver").describe("Paint color; one of the fifteen presets."),
135
+ color: colorSchema.default("silver"),
105
136
  size: z
106
137
  .enum(["thumb", "small", "medium", "large"])
107
138
  .optional()
@@ -126,10 +157,21 @@ export const imageInputSchema = z.object({
126
157
  .optional()
127
158
  .describe(`Margin around a trimmed car, percent of its longer side (0-${MAX_PADDING_PERCENT}). Only with trim.`),
128
159
  format: z
129
- .enum(FORMATS)
160
+ .enum(REQUEST_FORMATS)
130
161
  .default("png")
131
- .describe("png keeps the transparent background (default); webp is smallest; jpg is flattened onto white."),
132
- });
162
+ .describe("png keeps the transparent background (default); webp is smallest; jpg is flattened onto white; auto lets each viewer's Accept header choose webp or png, negotiated on every load of a signed URL. An inline image (get_car_image) is delivered as png for auto."),
163
+ })
164
+ .refine(namesOneVehicle, ONE_VEHICLE);
165
+ /**
166
+ * The encoding an inline image (`get_car_image`) is delivered in. `auto` is
167
+ * negotiated from an HTTP `Accept` header, which a tool call does not carry,
168
+ * so both servers deliver png for it: every MCP host decodes png, and the
169
+ * same input yields the same bytes over stdio and over HTTP. Signed URLs keep
170
+ * `auto` and negotiate per load.
171
+ */
172
+ export function inlineImageFormat(format) {
173
+ return format === "auto" ? "png" : format;
174
+ }
133
175
  export const MCP_TOOL_SCHEMAS = {
134
176
  get_car_image: imageInputSchema,
135
177
  create_car_image_urls: z.object({
@@ -163,6 +205,11 @@ export const MCP_TOOL_SCHEMAS = {
163
205
  .max(365)
164
206
  .optional()
165
207
  .describe("How long a renewable URL keeps renewing, 1 to 365 days from creation (default 365). Only with renew: true."),
208
+ idempotency_key: z
209
+ .string()
210
+ .regex(IDEMPOTENCY_KEY_PATTERN, 'Use 1-255 characters of letters, digits, ".", "_", ":" or "-".')
211
+ .optional()
212
+ .describe("Makes a retry safe. The same key with the same arguments within 24 hours replays the first result (idempotent_replayed: true) instead of minting and billing again; the same key with different arguments is refused; a retry that overtakes a call still running is told to wait. Pass one whenever the call might be repeated, e.g. one per listing or batch."),
166
213
  }),
167
214
  search_vehicles: z.object({
168
215
  query: z
@@ -189,11 +236,12 @@ export const MCP_TOOL_SCHEMAS = {
189
236
  .max(128)
190
237
  .optional()
191
238
  .describe("The request_id returned by get_car_image or create_car_image_urls (preferred way to identify the image)."),
192
- make: z.string().min(1).max(80).optional().describe("Alternative to request_id: identify the image by vehicle."),
239
+ vehicle: vehicleIdSchema.optional(),
240
+ make: z.string().min(1).max(80).optional().describe("Alternative to request_id: identify the image by vehicle (make, model, year, or a vehicle id)."),
193
241
  model: z.string().min(1).max(80).optional(),
194
242
  year: z.coerce.number().int().min(MIN_YEAR).max(2100).optional(),
195
243
  view: z.enum(VIEWS).optional(),
196
- color: z.enum(COLORS).optional(),
244
+ color: colorSchema.optional(),
197
245
  rating: z.number().int().min(1).max(5).optional().describe("1 (unusable) to 5 (perfect)."),
198
246
  verdict: z.enum(["good", "bad"]).optional().describe("Quick thumbs up/down; provide this or rating."),
199
247
  reason: z.string().max(500).optional().describe("What was wrong or right, e.g. 'wrong body style', 'perfect angle'."),
@@ -203,7 +251,36 @@ export const MCP_TOOL_SCHEMAS = {
203
251
  .string()
204
252
  .max(120)
205
253
  .optional()
206
- .describe('Filter by path fragment or keyword, e.g. "images/car", "image-urls", "feedback". Omit for the full compact reference.'),
254
+ .describe('Filter by path fragment or keyword, e.g. "images/car", "image-urls", "vin", "3d". Omit for the full compact reference.'),
255
+ }),
256
+ decode_vin: z.object({
257
+ vin: z
258
+ .string()
259
+ .min(5)
260
+ .max(40)
261
+ .describe("A full 17-character VIN, or a partial VIN of at least 5 characters with * for each unknown position. Case, spaces and dashes do not matter."),
262
+ year: z.coerce.number().int().min(1900).max(2100).optional().describe("Model-year hint for the decoder; it flags a mismatch with the VIN's own year position."),
263
+ }),
264
+ create_3d_model: z
265
+ .object({
266
+ ...vehicleFields,
267
+ color: colorSchema.default("silver"),
268
+ webhook_url: z
269
+ .string()
270
+ .url()
271
+ .max(2048)
272
+ .optional()
273
+ .describe("Public https URL that receives one POST {event: '3d_model.ready' | '3d_model.failed', data, sent_at} when the model settles; retried with backoff up to five times."),
274
+ webhook_secret: z.string().min(1).max(256).optional().describe("With webhook_url: the POST body is signed as X-CarImage-Signature: sha256=<hex HMAC of the raw body>."),
275
+ idempotency_key: z
276
+ .string()
277
+ .regex(/^[A-Za-z0-9._:-]{1,255}$/, "idempotency_key must be 1-255 characters of letters, digits, '.', '_', ':' or '-'")
278
+ .optional()
279
+ .describe("A retry with the same key replays the first answer instead of charging again (24 h); use it when a call may be repeated."),
280
+ })
281
+ .refine(namesOneVehicle, ONE_VEHICLE),
282
+ get_3d_model: z.object({
283
+ id: z.string().uuid().describe("The 3D request id returned by create_3d_model."),
207
284
  }),
208
285
  list_requests: z.object({
209
286
  kind: z.enum(REQUEST_KINDS).optional().describe("Only vehicle requests or only feature requests. Omit for both."),
@@ -266,11 +343,14 @@ export const MCP_TOOL_SCHEMAS = {
266
343
  */
267
344
  /** The vehicle echoed back with an image: exactly what would render it again. */
268
345
  const vehicleDescriptorSchema = z.looseObject({
346
+ /** Stable id of the catalog vehicle; null when the catalog cannot name one. */
347
+ vehicle_id: z.string().nullable(),
269
348
  make: z.string(),
270
349
  model: z.string(),
271
350
  year: z.number().int(),
272
351
  view: z.enum(VIEWS),
273
- color: z.enum(COLORS),
352
+ /** A preset name, or a hex paint as #rrggbb. */
353
+ color: z.string(),
274
354
  width: z.number().int().optional(),
275
355
  height: z.number().int().optional(),
276
356
  fit: z.enum(FITS).optional(),
@@ -340,6 +420,82 @@ const createdRequestResult = z.looseObject({
340
420
  deduplicated: z.boolean(),
341
421
  request_id: z.string(),
342
422
  });
423
+ /** The response of GET /api/v1/vin/{vin}: every key present, unknown values null. */
424
+ const vinResultSchema = z.looseObject({
425
+ vin: z.string(),
426
+ valid: z.boolean(),
427
+ errors: z.array(z.looseObject({ code: z.number().int(), text: z.string() })),
428
+ suggested_vin: z.string().nullable(),
429
+ year: z.number().int().nullable(),
430
+ make: z.string().nullable(),
431
+ model: z.string().nullable(),
432
+ trim: z.string().nullable(),
433
+ series: z.string().nullable(),
434
+ body_class: z.string().nullable(),
435
+ vehicle_type: z.string().nullable(),
436
+ doors: z.number().int().nullable(),
437
+ drive_type: z.string().nullable(),
438
+ fuel_type: z.string().nullable(),
439
+ engine: z.looseObject({
440
+ cylinders: z.number().int().nullable(),
441
+ displacement_l: z.number().nullable(),
442
+ hp: z.number().nullable(),
443
+ model: z.string().nullable(),
444
+ }),
445
+ transmission: z.looseObject({ style: z.string().nullable(), speeds: z.number().int().nullable() }),
446
+ manufacturer: z.string().nullable(),
447
+ plant: z.looseObject({ city: z.string().nullable(), state: z.string().nullable(), country: z.string().nullable() }),
448
+ gvwr: z.string().nullable(),
449
+ /** Every decoded vPIC variable verbatim. */
450
+ attributes: z.record(z.string(), z.string()),
451
+ /** The catalog vehicle the VIN maps to, with the id and path that render it; null when the catalog lacks it. */
452
+ vehicle: z.looseObject({ id: z.string(), make: z.string(), model: z.string(), year: z.number().int(), image_path: z.string() }).nullable(),
453
+ source: z.enum(["vpic-db", "vpic-api"]),
454
+ });
455
+ const model3dFileSchema = z.looseObject({
456
+ /** API URL that redirects to a short-lived signed download; needs the key. */
457
+ url: z.string(),
458
+ bytes: z.number().int(),
459
+ content_type: z.string(),
460
+ });
461
+ /** A 3D request as POST /api/v1/3d and GET /api/v1/3d/{id} return it. */
462
+ const model3dSchema = z.looseObject({
463
+ id: z.string(),
464
+ object: z.literal("3d_model"),
465
+ status: z.enum(["queued", "processing", "ready", "failed"]),
466
+ /** 0-100. */
467
+ progress: z.number(),
468
+ stage: z.string().nullable(),
469
+ vehicle: z.looseObject({ id: z.string().nullable(), make: z.string(), model: z.string(), year: z.number().int() }),
470
+ /** A preset name, or a hex paint as #rrggbb. */
471
+ color: z.string(),
472
+ generator: z.string(),
473
+ /** Present once status is ready. */
474
+ files: z
475
+ .looseObject({
476
+ glb: model3dFileSchema.optional(),
477
+ usdz: model3dFileSchema.optional(),
478
+ fbx: model3dFileSchema.optional(),
479
+ thumbnail: model3dFileSchema.optional(),
480
+ })
481
+ .nullable(),
482
+ polycount: z.number().int().nullable(),
483
+ /** Set when status is failed; the request was refunded. */
484
+ error: z.looseObject({ code: z.string(), message: z.string() }).nullable(),
485
+ estimated_seconds_remaining: z.number().nullable(),
486
+ webhook: z
487
+ .looseObject({
488
+ url: z.string(),
489
+ status: z.string().nullable(),
490
+ attempts: z.number().int(),
491
+ last_status: z.number().int().nullable(),
492
+ delivered_at: z.string().nullable(),
493
+ })
494
+ .nullable(),
495
+ created_at: z.string(),
496
+ updated_at: z.string(),
497
+ ready_at: z.string().nullable(),
498
+ });
343
499
  export const MCP_TOOL_OUTPUT_SCHEMAS = {
344
500
  get_car_image: z.looseObject({
345
501
  credits_charged: z.number().nullable(),
@@ -371,6 +527,8 @@ export const MCP_TOOL_OUTPUT_SCHEMAS = {
371
527
  renewal: z.looseObject({ window_seconds: z.number(), credits_per_window: z.number(), until: z.string() }).nullable().optional(),
372
528
  }),
373
529
  request_id: z.string(),
530
+ /** True when a retry was answered from the result stored for its idempotency_key; nothing was billed again. */
531
+ idempotent_replayed: z.boolean().optional(),
374
532
  }),
375
533
  search_vehicles: z.looseObject({
376
534
  data: z.looseObject({ query: z.string(), results: z.array(vehicleMatchSchema) }),
@@ -379,11 +537,13 @@ export const MCP_TOOL_OUTPUT_SCHEMAS = {
379
537
  data: z.looseObject({
380
538
  /** Ready to pass straight to get_car_image. */
381
539
  params: z.looseObject({
540
+ /** Stable id of the resolved vehicle; pass it as `vehicle` to render it again. */
541
+ vehicle_id: z.string().nullable(),
382
542
  make: z.string(),
383
543
  model: z.string(),
384
544
  year: z.number().int(),
385
545
  view: z.enum(VIEWS),
386
- color: z.enum(COLORS),
546
+ color: z.string(),
387
547
  }),
388
548
  display: z.looseObject({ make_name: z.string(), model_name: z.string() }).optional(),
389
549
  /** Other catalog vehicles that fit the phrase; ask when confidence is low. */
@@ -448,6 +608,17 @@ export const MCP_TOOL_OUTPUT_SCHEMAS = {
448
608
  }),
449
609
  request_id: z.string(),
450
610
  }),
611
+ decode_vin: z.looseObject({ data: vinResultSchema, request_id: z.string() }),
612
+ create_3d_model: z.looseObject({
613
+ data: model3dSchema,
614
+ billing: z.looseObject({
615
+ charged_on: z.literal("creation"),
616
+ credits_charged: z.number(),
617
+ credits_remaining: z.number(),
618
+ }),
619
+ request_id: z.string(),
620
+ }),
621
+ get_3d_model: z.looseObject({ data: model3dSchema, request_id: z.string() }),
451
622
  list_requests: requestListResult,
452
623
  request_vehicle: createdRequestResult,
453
624
  request_feature: createdRequestResult,
@@ -509,11 +680,37 @@ export function toImageOptions(data) {
509
680
  },
510
681
  };
511
682
  }
683
+ /** The one-line summary both servers put above a decoded VIN. */
684
+ export function vinSummary(result) {
685
+ const car = [result.year ?? "?", result.make ?? "unknown make", result.model ?? "", result.trim ?? ""].filter(Boolean).join(" ");
686
+ const notes = result.errors.length ? ` Decoder notes: ${result.errors.map((error) => error.text).join("; ")}.` : "";
687
+ if (result.vehicle) {
688
+ return `${result.vin}: ${car}. Catalog vehicle ${result.vehicle.id} (${result.vehicle.year} ${result.vehicle.make} ${result.vehicle.model}): pass it as vehicle to get_car_image, create_car_image_urls or create_3d_model.${notes}`;
689
+ }
690
+ return `${result.vin}: ${car}. Not in the image catalog; search_vehicles may find the model under another spelling.${notes}`;
691
+ }
692
+ /** The one-line summary both servers put above a 3D model, with the charge when it was just created. */
693
+ export function model3dSummary(model, billing) {
694
+ const car = `${model.vehicle.year} ${model.vehicle.make} ${model.vehicle.model} in ${model.color}`;
695
+ const charge = billing ? `Charged ${billing.credits_charged.toLocaleString("en-US")} credits, ${billing.credits_remaining.toLocaleString("en-US")} remaining. ` : "";
696
+ if (model.status === "ready") {
697
+ const files = Object.entries(model.files ?? {})
698
+ .filter((entry) => Boolean(entry[1]))
699
+ .map(([kind, file]) => `${kind} (${(file.bytes / 1_048_576).toFixed(1)} MB)`)
700
+ .join(", ");
701
+ return `${charge}3D model ${model.id} is ready: ${car}; files ${files || "none"}. Each files.<kind>.url redirects to a signed download valid for an hour (the API key is needed on the first hop only).`;
702
+ }
703
+ if (model.status === "failed") {
704
+ return `${charge}3D model ${model.id} failed: ${model.error?.message ?? "the model could not be generated"}. The credits were refunded; try again later or with another color.`;
705
+ }
706
+ const eta = model.estimated_seconds_remaining === null ? "" : `, about ${model.estimated_seconds_remaining} s left`;
707
+ return `${charge}3D model ${model.id} is ${model.status} (${model.progress}%${model.stage ? `, ${model.stage}` : ""}${eta}): ${car}. Poll get_3d_model(id) again in a few seconds; do not create it twice.`;
708
+ }
512
709
  export const MCP_TOOLS = {
513
710
  get_car_image: {
514
711
  name: "get_car_image",
515
712
  title: "Get car image",
516
- description: `Render or fetch a studio-quality, transparent-background image of a specific vehicle (make, model, year) from one of six camera angles in one of fifteen preset colors, at any width and height up to ${MAX_DIMENSION} px (fit contain|cover|inside), transparent or on a solid background, optionally trimmed to the car. Returns the image inline (PNG/WebP/JPG) plus usage metadata (credits_charged, credits_remaining, source cache|generated, request_id). COSTS ${CREDITS_PER_IMAGE} CREDIT per call, cached or generated. Use resolve_vehicle first when the request is free text; use create_car_image_urls instead when the image must be embedded in a web page or document.`,
713
+ description: `Render or fetch a studio-quality, transparent-background image of a specific vehicle (make, model and year, or its vehicle id) from one of six camera angles in any paint color (fifteen named presets or any hex such as #1a2b3c), at any width and height up to ${MAX_DIMENSION} px (fit contain|cover|inside), transparent or on a solid background, optionally trimmed to the car. Returns the image inline (PNG/WebP/JPG; format auto delivers PNG here) plus usage metadata (credits_charged, credits_remaining, source cache|generated, request_id, the vehicle with its vehicle_id). COSTS ${CREDITS_PER_IMAGE} CREDIT per call, cached or generated. Use resolve_vehicle first when the request is free text; use create_car_image_urls instead when the image must be embedded in a web page or document.`,
517
714
  inputSchema: MCP_TOOL_SCHEMAS.get_car_image,
518
715
  outputSchema: MCP_TOOL_OUTPUT_SCHEMAS.get_car_image,
519
716
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
@@ -521,7 +718,7 @@ export const MCP_TOOLS = {
521
718
  create_car_image_urls: {
522
719
  name: "create_car_image_urls",
523
720
  title: "Create signed car image URLs",
524
- description: "Create 1-50 signed, key-free delivery URLs that browsers, emails or documents can load directly (<img src>). Each URL costs 1 credit at creation; redemptions within the TTL are free and publicly cacheable. Each image takes the same sizing options as get_car_image (width, height, fit, background, trim). For email, CMS pages or documents that outlive a TTL, set renew: true with ttl_seconds 604800: the URL keeps serving past expiry at one more credit per opened week, for up to renew_days. Returns id, url, expires_at, max_uses, renews_until and the normalized vehicle for each image. Prefer this over get_car_image whenever the output is HTML, Markdown, a document or a website.",
721
+ description: "Create 1-50 signed, key-free delivery URLs that browsers, emails or documents can load directly (<img src>). Each URL costs 1 credit at creation; redemptions within the TTL are free and publicly cacheable. Each image names its vehicle like get_car_image (make, model, year, or a vehicle id), takes any paint color (a preset or a hex) and the same sizing options (width, height, fit, background, trim, padding); format auto makes the URL serve webp or png per viewer. For email, CMS pages or documents that outlive a TTL, set renew: true with ttl_seconds 604800: the URL keeps serving past expiry at one more credit per opened week, for up to renew_days. Pass idempotency_key when the call might be repeated: a retry with the same key and arguments replays the first result instead of billing again. Returns id, url, expires_at, max_uses, renews_until and the normalized vehicle for each image. Prefer this over get_car_image whenever the output is HTML, Markdown, a document or a website.",
525
722
  inputSchema: MCP_TOOL_SCHEMAS.create_car_image_urls,
526
723
  outputSchema: MCP_TOOL_OUTPUT_SCHEMAS.create_car_image_urls,
527
724
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
@@ -529,7 +726,7 @@ export const MCP_TOOLS = {
529
726
  search_vehicles: {
530
727
  name: "search_vehicles",
531
728
  title: "Search the vehicle catalog",
532
- description: `Free. Fuzzy-search the open vehicle catalog (${CATALOG_MAKES} makes, ${CATALOG_MODELS} models, ${CATALOG_YEARS}) by make and/or model with typo tolerance. Returns canonical make/model names, available years and match kind, ready to pass to get_car_image. Use it to confirm a vehicle exists or to list a make's models before rendering.`,
729
+ description: `Free. Fuzzy-search the open vehicle catalog (${CATALOG_MAKES} makes, ${CATALOG_MODELS} models, ${CATALOG_YEARS}) by make and/or model with typo tolerance. Returns canonical make/model names, available years and match kind, ready to pass to get_car_image (a model hit also carries stable vehicle ids per year, usable as \`vehicle\`). Use it to confirm a vehicle exists or to list a make's models before rendering.`,
533
730
  inputSchema: MCP_TOOL_SCHEMAS.search_vehicles,
534
731
  outputSchema: MCP_TOOL_OUTPUT_SCHEMAS.search_vehicles,
535
732
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
@@ -537,7 +734,7 @@ export const MCP_TOOLS = {
537
734
  resolve_vehicle: {
538
735
  name: "resolve_vehicle",
539
736
  title: "Resolve free text to image parameters",
540
- description: 'Free. Turn a natural-language request such as "red 2024 porsche 911 side view" into exact get_car_image parameters (make, model, year, view, color) plus alternative candidates and a confidence of high, medium or low. Call this before rendering when the user did not spell out the parameters; ask the user to choose when confidence is low or several candidates fit.',
737
+ description: 'Free. Turn a natural-language request such as "red 2024 porsche 911 side view" into exact get_car_image parameters (vehicle_id, make, model, year, view, color) plus alternative candidates and a confidence of high, medium or low. Call this before rendering when the user did not spell out the parameters; ask the user to choose when confidence is low or several candidates fit.',
541
738
  inputSchema: MCP_TOOL_SCHEMAS.resolve_vehicle,
542
739
  outputSchema: MCP_TOOL_OUTPUT_SCHEMAS.resolve_vehicle,
543
740
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
@@ -545,7 +742,7 @@ export const MCP_TOOLS = {
545
742
  list_image_options: {
546
743
  name: "list_image_options",
547
744
  title: "List image options",
548
- description: "Free. List the supported camera views (with yaw angles and aliases), the fifteen preset colors with hex swatches, size presets, output formats, current pricing and catalog coverage. Use it when you need to validate or explain what can be requested.",
745
+ description: "Free. List the supported camera views (with yaw angles and aliases), the fifteen preset colors with hex swatches (any other paint is a hex color), size presets, output formats, current pricing and catalog coverage. Use it when you need to validate or explain what can be requested.",
549
746
  inputSchema: MCP_TOOL_SCHEMAS.list_image_options,
550
747
  outputSchema: MCP_TOOL_OUTPUT_SCHEMAS.list_image_options,
551
748
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
@@ -561,7 +758,7 @@ export const MCP_TOOLS = {
561
758
  rate_image: {
562
759
  name: "rate_image",
563
760
  title: "Rate a delivered image",
564
- description: "Free. Record quality feedback on a delivered image, either by the request_id returned with it or by vehicle (make, model, year, view, color). Provide verdict good|bad or rating 1-5 and an optional reason. Feedback drives re-renders and prompt improvements.",
761
+ description: "Free. Record quality feedback on a delivered image, either by the request_id returned with it or by vehicle (make, model, year, or a vehicle id, plus view and color). Provide verdict good|bad or rating 1-5 and an optional reason. Feedback drives re-renders and prompt improvements.",
565
762
  inputSchema: MCP_TOOL_SCHEMAS.rate_image,
566
763
  outputSchema: MCP_TOOL_OUTPUT_SCHEMAS.rate_image,
567
764
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
@@ -573,6 +770,30 @@ export const MCP_TOOLS = {
573
770
  inputSchema: MCP_TOOL_SCHEMAS.describe_api,
574
771
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
575
772
  },
773
+ decode_vin: {
774
+ name: "decode_vin",
775
+ title: "Decode a VIN",
776
+ description: "Free. Decode a full 17-character VIN, or a partial VIN of at least 5 characters with * for unknown positions, with NHTSA vPIC data: year, make, model, trim, series, body class, engine, transmission, manufacturer, plant and every decoded attribute. `vehicle` is the catalog vehicle it maps to, with the stable id to pass as `vehicle` to get_car_image, create_car_image_urls or create_3d_model, or null when the catalog does not carry that car. Use it whenever the human gives a VIN instead of a make and model.",
777
+ inputSchema: MCP_TOOL_SCHEMAS.decode_vin,
778
+ outputSchema: MCP_TOOL_OUTPUT_SCHEMAS.decode_vin,
779
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
780
+ },
781
+ create_3d_model: {
782
+ name: "create_3d_model",
783
+ title: "Create a 3D model",
784
+ description: `COSTS ${MODEL_3D_PRICE} PER CALL, charged when the request is made whether the model is cached, in progress or new: confirm with the human before creating one. Build a textured 3D model (GLB, USDZ, FBX and a PNG thumbnail) of one catalog vehicle (make, model and year, or a vehicle id) in one paint color (a preset or any hex), from the same renders the images use, so it matches the pictures. A failed model is refunded. Returns the request at once with status queued, processing or ready (cached), progress 0-100 and estimated_seconds_remaining; poll get_3d_model every few seconds until status is ready, then hand over files.<kind>.url (API URLs that redirect to short-lived signed downloads), or pass webhook_url to be POSTed the same JSON when it settles. A model takes one to five minutes.`,
785
+ inputSchema: MCP_TOOL_SCHEMAS.create_3d_model,
786
+ outputSchema: MCP_TOOL_OUTPUT_SCHEMAS.create_3d_model,
787
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
788
+ },
789
+ get_3d_model: {
790
+ name: "get_3d_model",
791
+ title: "Get a 3D model",
792
+ description: "Free. The state of one 3D request by id: status (queued, processing, ready, failed), progress 0-100, stage, estimated_seconds_remaining, the vehicle and color, and once ready the files (glb, usdz, fbx, thumbnail) with their download URLs, byte sizes and content types. Poll it every few seconds after create_3d_model; a processing model is re-checked with the provider on each call. A failed model carries error and was refunded.",
793
+ inputSchema: MCP_TOOL_SCHEMAS.get_3d_model,
794
+ outputSchema: MCP_TOOL_OUTPUT_SCHEMAS.get_3d_model,
795
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
796
+ },
576
797
  list_requests: {
577
798
  name: "list_requests",
578
799
  title: "List vehicle and feature requests",
@@ -648,11 +869,12 @@ export const API_REFERENCE = [
648
869
  auth: "bearer",
649
870
  credits: "1 per call (cached or generated)",
650
871
  params: [
651
- "make (required)",
652
- "model (required)",
653
- `year (required, ${CATALOG_YEARS})`,
872
+ "make (required unless vehicle is given)",
873
+ "model (required unless vehicle is given)",
874
+ `year (required unless vehicle is given, ${CATALOG_YEARS})`,
875
+ "vehicle (a stable vehicle id such as veh_395yw8tn73ff8, from /api/v1/vehicles, /api/v1/vin or resolve; replaces make, model and year, never alongside them)",
654
876
  `view (${VIEWS.join("|")}; default front-3-4)`,
655
- `color (${COLORS.join("|")}; default silver)`,
877
+ `color (${COLORS.join("|")}, or any hex paint written bare in URLs such as 1a2b3c; default silver; JSON echoes a hex as #1a2b3c)`,
656
878
  "size (thumb=256|small=512|medium=768|large=1024)",
657
879
  `w, h (1-${MAX_DIMENSION} px; both -> the output is exactly w x h)`,
658
880
  `fit (${FITS.join("|")}; default contain; only matters with both w and h)`,
@@ -660,11 +882,11 @@ export const API_REFERENCE = [
660
882
  `trim (1 crops to the car's alpha bounds before sizing), padding (0-${MAX_PADDING_PERCENT} percent, only with trim)`,
661
883
  `format (${FORMATS.join("|")}|auto; default png; auto negotiates webp/png from Accept)`,
662
884
  ],
663
- returns: "image bytes; headers X-Credits-Charged, X-Credits-Remaining, X-Image-Source (cache|generated), X-Image-Width, X-Image-Height, ETag, X-Request-Id (Vary: Accept with format=auto). With Accept: application/json: {data:{url,expires_at,vehicle,width,height,format}, billing:{credits_charged,credits_remaining}, request_id}",
664
- errors: ["400 invalid params", "401 missing/invalid key", "402 insufficient credits (balance, required_credits)", "404 vehicle not in catalog", "429 rate limited (Retry-After)", "502 render failed (refunded)"],
885
+ returns: "image bytes; headers X-Credits-Charged, X-Credits-Remaining, X-Image-Source (cache|generated), X-Image-Width, X-Image-Height, ETag, X-Request-Id (Vary: Accept with format=auto). With Accept: application/json: {data:{url,expires_at,vehicle:{vehicle_id,make,model,year,view,color,…},width,height,format}, billing:{credits_charged,credits_remaining}, request_id}",
886
+ errors: ["400 invalid params (also vehicle together with make/model/year)", "401 missing/invalid key", "402 insufficient credits (balance, required_credits)", "404 vehicle not in catalog or unknown vehicle id", "429 rate limited (Retry-After)", "502 render failed (refunded)"],
665
887
  notes: "Do not purchase credits automatically on 402; ask the human. Respect Retry-After on 429.",
666
- sdk: "client.getImage({ make, model, year, view, color, size, format }) / client.getImageUrl(...)",
667
- cli: "car-image get --make Porsche --model 911 --year 2024 --view side --color red --out car.png",
888
+ sdk: "client.getImage({ make, model, year, view, color, size, width, height, fit, background, trim, padding, format }) / client.getImage({ vehicle: 'veh_…', color: '#1a2b3c' }) / client.getImageUrl(...)",
889
+ cli: "car-image get --make Porsche --model 911 --year 2024 --view side --color red --out car.png · car-image get --vehicle veh_395yw8tn73ff8 --color 1a2b3c",
668
890
  },
669
891
  {
670
892
  method: "POST",
@@ -672,10 +894,10 @@ export const API_REFERENCE = [
672
894
  summary: "Create 1-50 signed delivery URLs for browsers (no key needed to load them).",
673
895
  auth: "bearer",
674
896
  credits: "1 per URL, charged at creation; redemptions are free",
675
- params: ["images: [{make, model, year, view?, color?, size?, width?, height?, fit?, background?, trim?, padding?, format?}] (or a single image object)", "ttl_seconds (60-604800; default 3600)", "max_uses (0 = unlimited; default 0)", "renew (auto-renew past the TTL at 1 credit per opened window; requires max_uses 0)", "renew_days (1-365; default 365)", "header Idempotency-Key (optional; a retry with the same key and body replays the first response instead of billing again)"],
676
- returns: "201 {data:[{id,url,expires_at,max_uses,renews_until,vehicle}], billing:{charged_on:'creation',credits_charged,credits_remaining,credits_per_url,renewal?}, request_id}; a replay carries Idempotent-Replayed: true",
897
+ params: ["images: [{make, model, year | vehicle, view?, color? (preset or hex), size?, width?, height?, fit?, background?, trim?, padding?, format?}] (or a single image object)", "ttl_seconds (60-604800; default 3600)", "max_uses (0 = unlimited; default 0)", "renew (auto-renew past the TTL at 1 credit per opened window; requires max_uses 0)", "renew_days (1-365; default 365)", "header Idempotency-Key (optional; a retry with the same key and body replays the first response instead of billing again)"],
898
+ returns: "201 {data:[{id,url,expires_at,max_uses,renews_until,vehicle:{vehicle_id,…}}], billing:{charged_on:'creation',credits_charged,credits_remaining,credits_per_url,renewal?}, request_id}; a replay carries Idempotent-Replayed: true",
677
899
  errors: ["400 invalid body or batch > 50", "401", "402", "404 vehicle not in catalog", "409 same Idempotency-Key still in flight", "422 same Idempotency-Key with a different body", "429"],
678
- sdk: "client.createImageUrls([{ make, model, year }], { ttlSeconds, maxUses, renew, renewDays })",
900
+ sdk: "client.createImageUrls([{ make, model, year, ...sizing }, { vehicle: 'veh_…' }], { ttlSeconds, maxUses, renew, renewDays, idempotencyKey })",
679
901
  cli: "car-image url --make BMW --model M3 --year 2022 --ttl 86400 [--renew] [--idempotency-key <key>]",
680
902
  },
681
903
  {
@@ -693,7 +915,7 @@ export const API_REFERENCE = [
693
915
  summary: "Views, colors, sizes, formats, pricing and catalog coverage.",
694
916
  auth: "public",
695
917
  credits: "free",
696
- returns: "{data:{views:[{id,label,yaw_degrees,description,aliases}], colors:[{name,hex}], sizes:{presets,max,source}, fits, default_fit, backgrounds, trim, formats, pricing:{credits_per_image,credits_per_dollar,free_credits}, catalog:{makes,models,years,sources}}}",
918
+ returns: "{data:{views:[{id,label,yaw_degrees,description,aliases}], colors:[{name,hex}], paint:{parameter,custom,example}, sizes:{presets,max,source}, fits, default_fit, backgrounds, trim, formats, pricing:{credits_per_image,credits_per_dollar,free_credits}, catalog:{makes,models,years,sources}, vehicle_ids:{description,example,lookup,parameter}}}",
697
919
  sdk: "client.options()",
698
920
  cli: "car-image options",
699
921
  },
@@ -704,28 +926,100 @@ export const API_REFERENCE = [
704
926
  auth: "bearer",
705
927
  credits: "free",
706
928
  params: ['query: "red 2024 porsche 911 side view"'],
707
- returns: "{data:{params:{make,model,year,view,color}, display:{make_name,model_name}, candidates:[...], confidence:high|medium|low, image_path}}",
929
+ returns: "{data:{params:{vehicle_id,make,model,year,view,color}, display:{make_name,model_name}, candidates:[...], confidence:high|medium|low, image_path}}",
708
930
  sdk: "client.resolve(query)",
709
931
  cli: "car-image resolve red 2024 porsche 911 side view",
710
932
  },
711
933
  {
712
934
  method: "GET",
713
935
  path: "/api/v1/vehicles",
714
- summary: "Browse or search the catalog.",
936
+ summary: "Browse or search the catalog; every model in a known year carries its stable vehicle id.",
715
937
  auth: "public",
716
938
  credits: "free",
717
- params: ["(none) -> years", "year -> makes [{id,name}]", "year + makeId -> models", "q (+ limit) -> fuzzy search results"],
718
- returns: "{data:{years}} | {data:{year,makes}} | {data:{year,make_id,models}} | {data:{results}}",
719
- sdk: "client.vehicles({ year, makeId }) / client.searchVehicles(q, { limit })",
939
+ params: ["(none) -> years", "year -> makes [{id,name,slug}]", "year + makeId -> models [{name,slug,vehicle_type,id}]", "make (slug) [+ year] -> that make's models", "make + model (slugs) -> the model's years, each with its id", "q (+ limit, year) -> fuzzy search results; a model hit carries ids {year: id} and id for the year the query named"],
940
+ returns: "{data:{years}} | {data:{year,makes}} | {data:{year,make_id,models}} | {data:{make,models}} | {data:{make,model,years,year_ranges,vehicles:[{year,id}]}} | {data:{query,results:[{kind,make_name,make_slug,model_name,model_slug,vehicle_type,years,year_ranges,match_kind,id?,ids?}]}}",
941
+ sdk: "client.vehicles({ year, makeId }) / client.vehicles({ make, model }) / client.searchVehicles(q, { limit, year })",
720
942
  cli: "car-image search porsche 911",
721
943
  },
944
+ {
945
+ method: "GET",
946
+ path: "/api/v1/vehicles/{id}",
947
+ summary: "The catalog vehicle a stable id names, with its years and the image URLs that render it.",
948
+ auth: "public",
949
+ credits: "free",
950
+ returns: "{data:{id, make:{id,name,slug}, model:{name,slug,vehicle_type}, year, years, year_ranges, image_path, images:{front,front-3-4,side,side-right,rear,rear-3-4}}, request_id}",
951
+ errors: ["400 not a vehicle id", "404 unknown id"],
952
+ notes: "Ids are a pure function of the catalog spelling and never change; store them instead of make/model/year strings.",
953
+ sdk: "client.vehicle('veh_395yw8tn73ff8')",
954
+ cli: "car-image get --vehicle veh_395yw8tn73ff8",
955
+ },
956
+ {
957
+ method: "GET",
958
+ path: "/api/v1/vin/{vin}",
959
+ summary: "Decode a full or partial VIN (NHTSA vPIC) and name the catalog vehicle it maps to.",
960
+ auth: "bearer",
961
+ credits: "free",
962
+ params: ["vin in the path: 17 characters, or a partial VIN of 5+ characters with * for each unknown position (case, spaces and dashes ignored)", "year (optional model-year hint)"],
963
+ returns: "{data:{vin, valid, errors:[{code,text}], suggested_vin, year, make, model, trim, series, body_class, vehicle_type, doors, drive_type, fuel_type, engine:{cylinders,displacement_l,hp,model}, transmission:{style,speeds}, manufacturer, plant:{city,state,country}, gvwr, attributes:{…every decoded variable}, vehicle:{id,make,model,year,image_path}|null, source:vpic-db|vpic-api}, request_id}",
964
+ errors: ["400 invalid VIN or year", "401", "404 VIN not recognized", "502 both decoders unavailable"],
965
+ notes: "vehicle.id is a stable vehicle id: pass it as vehicle= to /api/v1/images/car, /api/v1/image-urls or /api/v1/3d. vehicle is null when the catalog does not carry the car.",
966
+ sdk: "client.decodeVin('1HGCM82633A004352', { year: 2003 })",
967
+ cli: "car-image vin 1HGCM82633A004352",
968
+ },
969
+ {
970
+ method: "POST",
971
+ path: "/api/v1/3d",
972
+ summary: "Create a textured 3D model (GLB, USDZ, FBX and a thumbnail) of one vehicle in one paint color.",
973
+ auth: "bearer",
974
+ credits: `${MODEL_3D_PRICE} per model at launch (credits_per_model, reported by GET /api/v1/3d), charged at creation whether the model is cached, in progress or new; a failed model is refunded; polls and downloads are free`,
975
+ params: ["make, model, year — or vehicle (a veh_… id), never both", "color (preset or hex such as #1a2b3c; default silver)", "webhook_url (https, public host; receives one POST {event:'3d_model.ready'|'3d_model.failed', data, sent_at} with X-CarImage-Event and X-CarImage-Delivery, retried up to five times)", "webhook_secret (with webhook_url: X-CarImage-Signature: sha256=<hex HMAC of the raw body>)", "header Idempotency-Key (optional; same rules as /api/v1/image-urls)"],
976
+ returns: "202 while queued or processing, 200 when already ready: {data:{id, object:'3d_model', status:queued|processing|ready|failed, progress:0-100, stage, vehicle:{id,make,model,year}, color, generator, files:{glb|usdz|fbx|thumbnail:{url,bytes,content_type}}|null, polycount, error, estimated_seconds_remaining, webhook, created_at, updated_at, ready_at}, billing:{charged_on:'creation',credits_charged,credits_remaining}, request_id}; Location: /api/v1/3d/{id}",
977
+ errors: ["400 invalid body or webhook URL", "401", "402 insufficient credits", "404 vehicle not in catalog", "409/422 Idempotency-Key conflicts", "503 3D models disabled or at daily capacity (Retry-After; nothing charged)"],
978
+ notes: "Ask the human before spending. A model takes one to five minutes: poll GET /api/v1/3d/{id} every few seconds or use the webhook; never re-POST to check progress.",
979
+ sdk: "client.create3dModel({ make, model, year } | { vehicle }, { color, webhookUrl, webhookSecret, idempotencyKey }) then client.wait3dModel(id)",
980
+ cli: "car-image 3d create --make Toyota --model Camry --year 2025 --color 1a2b3c --wait --out ./models",
981
+ },
982
+ {
983
+ method: "GET",
984
+ path: "/api/v1/3d",
985
+ summary: "The caller's recent 3D requests, newest first, with the current price per model.",
986
+ auth: "bearer",
987
+ credits: "free",
988
+ params: ["limit (1-50; default 20)"],
989
+ returns: "{data:[3d_model…], pricing:{credits_per_model}, request_id}",
990
+ sdk: "client.list3dModels({ limit: 20 })",
991
+ cli: "car-image 3d list",
992
+ },
993
+ {
994
+ method: "GET",
995
+ path: "/api/v1/3d/{id}",
996
+ summary: "Status, progress and files of one 3D request; a processing model is re-checked with the provider.",
997
+ auth: "bearer",
998
+ credits: "free",
999
+ returns: "{data: 3d_model, request_id}",
1000
+ errors: ["404 unknown id (ids are scoped to the account)"],
1001
+ sdk: "client.get3dModel(id) / client.wait3dModel(id, { intervalMs, timeoutMs, onProgress })",
1002
+ cli: "car-image 3d get <id> --wait",
1003
+ },
1004
+ {
1005
+ method: "GET",
1006
+ path: "/api/v1/3d/{id}/files/{kind}",
1007
+ summary: `One file of a ready model (kind: ${MODEL_3D_FILE_KINDS.join("|")}): a 302 to a signed URL valid for an hour.`,
1008
+ auth: "bearer",
1009
+ credits: "free",
1010
+ returns: "302 Location: <signed storage URL>; X-Content-Length, X-File-Content-Type",
1011
+ errors: ["404 unknown id or kind", "409 model not ready yet (Retry-After: 15)"],
1012
+ notes: "Follow the redirect without the Authorization header; the signed URL needs no key. files.<kind>.url on the model JSON is this endpoint.",
1013
+ sdk: "client.download3dModel(id, 'glb') // { bytes, contentType }",
1014
+ cli: "car-image 3d download <id> --format glb --out model.glb",
1015
+ },
722
1016
  {
723
1017
  method: "POST",
724
1018
  path: "/api/v1/feedback",
725
1019
  summary: "Rate a delivered image.",
726
1020
  auth: "bearer",
727
1021
  credits: "free",
728
- params: ["request_id OR make, model, year (+ view, color)", "rating 1-5 and/or verdict good|bad", "reason (optional)"],
1022
+ params: ["request_id OR make, model, year (+ view, color as a preset or hex)", "rating 1-5 and/or verdict good|bad", "reason (optional)"],
729
1023
  returns: "201 {data:{...}, request_id}",
730
1024
  sdk: "client.feedback({ requestId, verdict: 'good' })",
731
1025
  cli: "car-image feedback --request-id <id> --good",
@@ -890,7 +1184,8 @@ export function formatApiReference(filter) {
890
1184
  const header = [
891
1185
  `Car Image API — base URL ${DEFAULT_BASE_URL}`,
892
1186
  `Auth: Authorization: Bearer cimg_… (never in URLs). Errors: application/problem+json {type,title,status,detail,request_id}.`,
893
- `Pricing: ${CREDITS_PER_IMAGE} credit per delivered image, $1 = ${CREDITS_PER_DOLLAR} credits, ${FREE_CREDITS} free credits, no subscription.`,
1187
+ `Pricing: ${CREDITS_PER_IMAGE} credit per delivered image, $1 = ${CREDITS_PER_DOLLAR} credits, ${FREE_CREDITS} free credits, no subscription; a 3D model is ${MODEL_3D_PRICE}.`,
1188
+ `Vehicles: make + model + year, or vehicle=<stable id such as veh_395yw8tn73ff8> (from /api/v1/vehicles, /api/v1/vin or resolve), never both. Colors: ${COLORS.length} presets or any hex paint (URLs: color=1a2b3c bare; JSON: "#1a2b3c" or "1a2b3c"; responses echo #1a2b3c).`,
894
1189
  "",
895
1190
  ];
896
1191
  if (endpoints.length === 0) {
@@ -937,9 +1232,13 @@ export function nextStepFor(status) {
937
1232
  case 403:
938
1233
  return "This key lacks the required scope. Ask the human to create a key with the right scopes in the dashboard.";
939
1234
  case 404:
940
- return "The vehicle is not in the catalog. Use search_vehicles or resolve_vehicle to find the canonical make/model/year.";
1235
+ return "The vehicle is not in the catalog (or the id is unknown). Use search_vehicles, resolve_vehicle or decode_vin to find the canonical make/model/year or its vehicle id.";
1236
+ case 409:
1237
+ return "Not ready or still in progress (a 3D model still being made, or an Idempotency-Key request still running). Wait the retry_after seconds, then poll again; do not create a second one.";
941
1238
  case 429:
942
1239
  return "Rate limited. Wait the retry_after seconds before retrying; do not hammer the API.";
1240
+ case 503:
1241
+ return "Temporarily unavailable (a feature is switched off or at its daily capacity); nothing was charged. Wait the retry_after seconds before trying again, and tell the human if it persists.";
943
1242
  default:
944
1243
  return "Retry once if this looks transient; otherwise report the detail and request_id to the human.";
945
1244
  }