Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 43 additions & 7 deletions .github/scripts/snippets/gen-code-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,44 @@ ${body}
/** The one-line body placeholder for a model whose request fields Router does not publish. */
const BODY_HINT = "Request fields are the provider's own \u2014 see Input below.";

function derivedSnippets(model: string): string {
/**
* The published input example, when it is a JSON object we can render as a body.
*
* An authored model carries one and it is a REAL call: openapi.yml takes it from
* that model's end-to-end smoke case, and routervalidate's
* TestAuthoredModelsAreValidatedAgainstTheirOwnSchema runs it through the same
* validator that guards live traffic, so it necessarily carries every required
* field. Inlining it is what makes the quick start copy-pasteable rather than a
* shape the reader has to assemble from the Input table below.
*
* Anything else -- absent, null, or a non-object -- falls back to BODY_HINT.
* That is the unauthored case, where Router genuinely cannot state the fields
* and a fabricated body would be worse than an honest placeholder.
*/
function bodyExample(example: unknown): Record<string, unknown> | undefined {
if (example === null || typeof example !== "object" || Array.isArray(example)) return undefined;
const entries = Object.entries(example as Record<string, unknown>);
return entries.length > 0 ? (example as Record<string, unknown>) : undefined;
}

function derivedSnippets(model: string, example?: unknown): string {
// Rendered through the same pyLiteral/tsLiteral/esc helpers the curated
// snippets use, so the three languages cannot drift from one another or from
// the JSON in the Examples section -- the invariant stated at the top of this
// file. Derived pages have no file inputs, so the FileInput list is empty.
const body = bodyExample(example);
const pyBody = body
? Object.entries(body).map(([k, v]) => ` ${JSON.stringify(k)}: ${pyLiteral(v, 12, [], k)},`).join("\n")
: ` # ${BODY_HINT}`;
const tsBody = body
? Object.entries(body).map(([k, v]) => ` ${/^[a-zA-Z_$][\w$]*$/.test(k) ? k : JSON.stringify(k)}: ${tsLiteral(v, 2, [], k)},`).join("\n")
: ` // ${BODY_HINT}`;
const esc = (v: unknown) => JSON.stringify(v).replace(/[\\$`"]/g, (c) => `\\${c}`);
const curlJson = body
? `{${Object.entries(body).map(([k, v]) => `${esc(k)}: ${esc(v)}`).join(", ")}}`
: "{}";
const curlHint = body ? "" : `# ${BODY_HINT}\n`;

const python = `from comfy_sdk import Comfy

# Reads COMFY_API_KEY from the environment. Each call sends a fresh
Expand All @@ -682,7 +719,7 @@ with Comfy() as client:
result = client.models.run(
"${model}",
{
# ${BODY_HINT}
${pyBody}
},
)

Expand All @@ -692,16 +729,15 @@ print(result)`;
// Reads COMFY_API_KEY from the environment. Each call sends a fresh
// Idempotency-Key and waits up to 10 minutes for the finished result.
const { data } = await comfy.models.run("${model}", {
// ${BODY_HINT}
${tsBody}
});

console.log(data);`;
const curl = `# ${BODY_HINT}
curl ${BASE_URL}${ROUTE}/${model} \\
const curl = `${curlHint}curl ${BASE_URL}${ROUTE}/${model} \\
-H "X-API-Key: $COMFY_API_KEY" \\
-H "Idempotency-Key: $(uuidgen)" \\
-H "Content-Type: application/json" \\
-d '{}'`;
-d "${curlJson}"`;
return `<CodeGroup>
\`\`\`python Python
${python}
Expand Down Expand Up @@ -752,7 +788,7 @@ ${setup}

**Endpoint:** \`POST ${BASE_URL}${ROUTE}/${model}\`

${derivedSnippets(model)}
${derivedSnippets(model, s.inputExample)}

## Schema

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
result = client.models.run(
"anthropic/claude-fable-5-1",
{
# Request fields are the provider's own — see Input below.
"max_tokens": 16,
"messages": [
{
"content": "Reply with the single word: ok",
"role": "user",
},
],
},
)

Expand All @@ -41,19 +47,24 @@
// Reads COMFY_API_KEY from the environment. Each call sends a fresh
// Idempotency-Key and waits up to 10 minutes for the finished result.
const { data } = await comfy.models.run("anthropic/claude-fable-5-1", {
// Request fields are the provider's own — see Input below.
max_tokens: 16,
messages: [
{
content: "Reply with the single word: ok",
role: "user",
},
],
});

console.log(data);
```

```bash cURL
# Request fields are the provider's own — see Input below.
curl https://api.comfy.org/v2/models/anthropic/claude-fable-5-1 \
-H "X-API-Key: $COMFY_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'
-d "{\"max_tokens\": 16, \"messages\": [{\"content\":\"Reply with the single word: ok\",\"role\":\"user\"}]}"
```
</CodeGroup>

Expand All @@ -70,7 +81,7 @@
</ParamField>

<ParamField body="messages[].content" type="object" required>
Either a string shorthand or an array of content blocks (text, image, document, tool_use, tool_result, ...).

Check warning on line 84 in development/comfy-router/models/anthropic/claude-fable-5-1/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-fable-5-1/code.mdx#L84

Did you really mean 'tool_use'?

Check warning on line 84 in development/comfy-router/models/anthropic/claude-fable-5-1/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-fable-5-1/code.mdx#L84

Did you really mean 'tool_result'?
</ParamField>

<ParamField body="messages[].role" type="string" required>
Expand Down
19 changes: 15 additions & 4 deletions development/comfy-router/models/anthropic/claude-fable-5/code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
result = client.models.run(
"anthropic/claude-fable-5",
{
# Request fields are the provider's own — see Input below.
"max_tokens": 16,
"messages": [
{
"content": "Reply with the single word: ok",
"role": "user",
},
],
},
)

Expand All @@ -41,19 +47,24 @@
// Reads COMFY_API_KEY from the environment. Each call sends a fresh
// Idempotency-Key and waits up to 10 minutes for the finished result.
const { data } = await comfy.models.run("anthropic/claude-fable-5", {
// Request fields are the provider's own — see Input below.
max_tokens: 16,
messages: [
{
content: "Reply with the single word: ok",
role: "user",
},
],
});

console.log(data);
```

```bash cURL
# Request fields are the provider's own — see Input below.
curl https://api.comfy.org/v2/models/anthropic/claude-fable-5 \
-H "X-API-Key: $COMFY_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'
-d "{\"max_tokens\": 16, \"messages\": [{\"content\":\"Reply with the single word: ok\",\"role\":\"user\"}]}"
```
</CodeGroup>

Expand All @@ -70,7 +81,7 @@
</ParamField>

<ParamField body="messages[].content" type="object" required>
Either a string shorthand or an array of content blocks (text, image, document, tool_use, tool_result, ...).

Check warning on line 84 in development/comfy-router/models/anthropic/claude-fable-5/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-fable-5/code.mdx#L84

Did you really mean 'tool_use'?

Check warning on line 84 in development/comfy-router/models/anthropic/claude-fable-5/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-fable-5/code.mdx#L84

Did you really mean 'tool_result'?
</ParamField>

<ParamField body="messages[].role" type="string" required>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
result = client.models.run(
"anthropic/claude-haiku-4-5-20251001",
{
# Request fields are the provider's own — see Input below.
"max_tokens": 16,
"messages": [
{
"content": "Reply with the single word: ok",
"role": "user",
},
],
},
)

Expand All @@ -41,19 +47,24 @@
// Reads COMFY_API_KEY from the environment. Each call sends a fresh
// Idempotency-Key and waits up to 10 minutes for the finished result.
const { data } = await comfy.models.run("anthropic/claude-haiku-4-5-20251001", {
// Request fields are the provider's own — see Input below.
max_tokens: 16,
messages: [
{
content: "Reply with the single word: ok",
role: "user",
},
],
});

console.log(data);
```

```bash cURL
# Request fields are the provider's own — see Input below.
curl https://api.comfy.org/v2/models/anthropic/claude-haiku-4-5-20251001 \
-H "X-API-Key: $COMFY_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'
-d "{\"max_tokens\": 16, \"messages\": [{\"content\":\"Reply with the single word: ok\",\"role\":\"user\"}]}"
```
</CodeGroup>

Expand All @@ -70,7 +81,7 @@
</ParamField>

<ParamField body="messages[].content" type="object" required>
Either a string shorthand or an array of content blocks (text, image, document, tool_use, tool_result, ...).

Check warning on line 84 in development/comfy-router/models/anthropic/claude-haiku-4-5-20251001/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-haiku-4-5-20251001/code.mdx#L84

Did you really mean 'tool_use'?

Check warning on line 84 in development/comfy-router/models/anthropic/claude-haiku-4-5-20251001/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-haiku-4-5-20251001/code.mdx#L84

Did you really mean 'tool_result'?
</ParamField>

<ParamField body="messages[].role" type="string" required>
Expand Down
19 changes: 15 additions & 4 deletions development/comfy-router/models/anthropic/claude-opus-4-6/code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
result = client.models.run(
"anthropic/claude-opus-4-6",
{
# Request fields are the provider's own — see Input below.
"max_tokens": 16,
"messages": [
{
"content": "Reply with the single word: ok",
"role": "user",
},
],
},
)

Expand All @@ -41,19 +47,24 @@
// Reads COMFY_API_KEY from the environment. Each call sends a fresh
// Idempotency-Key and waits up to 10 minutes for the finished result.
const { data } = await comfy.models.run("anthropic/claude-opus-4-6", {
// Request fields are the provider's own — see Input below.
max_tokens: 16,
messages: [
{
content: "Reply with the single word: ok",
role: "user",
},
],
});

console.log(data);
```

```bash cURL
# Request fields are the provider's own — see Input below.
curl https://api.comfy.org/v2/models/anthropic/claude-opus-4-6 \
-H "X-API-Key: $COMFY_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'
-d "{\"max_tokens\": 16, \"messages\": [{\"content\":\"Reply with the single word: ok\",\"role\":\"user\"}]}"
```
</CodeGroup>

Expand All @@ -70,7 +81,7 @@
</ParamField>

<ParamField body="messages[].content" type="object" required>
Either a string shorthand or an array of content blocks (text, image, document, tool_use, tool_result, ...).

Check warning on line 84 in development/comfy-router/models/anthropic/claude-opus-4-6/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-opus-4-6/code.mdx#L84

Did you really mean 'tool_use'?

Check warning on line 84 in development/comfy-router/models/anthropic/claude-opus-4-6/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-opus-4-6/code.mdx#L84

Did you really mean 'tool_result'?
</ParamField>

<ParamField body="messages[].role" type="string" required>
Expand Down
19 changes: 15 additions & 4 deletions development/comfy-router/models/anthropic/claude-opus-4-7/code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
result = client.models.run(
"anthropic/claude-opus-4-7",
{
# Request fields are the provider's own — see Input below.
"max_tokens": 16,
"messages": [
{
"content": "Reply with the single word: ok",
"role": "user",
},
],
},
)

Expand All @@ -41,19 +47,24 @@
// Reads COMFY_API_KEY from the environment. Each call sends a fresh
// Idempotency-Key and waits up to 10 minutes for the finished result.
const { data } = await comfy.models.run("anthropic/claude-opus-4-7", {
// Request fields are the provider's own — see Input below.
max_tokens: 16,
messages: [
{
content: "Reply with the single word: ok",
role: "user",
},
],
});

console.log(data);
```

```bash cURL
# Request fields are the provider's own — see Input below.
curl https://api.comfy.org/v2/models/anthropic/claude-opus-4-7 \
-H "X-API-Key: $COMFY_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'
-d "{\"max_tokens\": 16, \"messages\": [{\"content\":\"Reply with the single word: ok\",\"role\":\"user\"}]}"
```
</CodeGroup>

Expand All @@ -70,7 +81,7 @@
</ParamField>

<ParamField body="messages[].content" type="object" required>
Either a string shorthand or an array of content blocks (text, image, document, tool_use, tool_result, ...).

Check warning on line 84 in development/comfy-router/models/anthropic/claude-opus-4-7/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-opus-4-7/code.mdx#L84

Did you really mean 'tool_use'?

Check warning on line 84 in development/comfy-router/models/anthropic/claude-opus-4-7/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-opus-4-7/code.mdx#L84

Did you really mean 'tool_result'?
</ParamField>

<ParamField body="messages[].role" type="string" required>
Expand Down
19 changes: 15 additions & 4 deletions development/comfy-router/models/anthropic/claude-opus-4-8/code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
result = client.models.run(
"anthropic/claude-opus-4-8",
{
# Request fields are the provider's own — see Input below.
"max_tokens": 16,
"messages": [
{
"content": "Reply with the single word: ok",
"role": "user",
},
],
},
)

Expand All @@ -41,19 +47,24 @@
// Reads COMFY_API_KEY from the environment. Each call sends a fresh
// Idempotency-Key and waits up to 10 minutes for the finished result.
const { data } = await comfy.models.run("anthropic/claude-opus-4-8", {
// Request fields are the provider's own — see Input below.
max_tokens: 16,
messages: [
{
content: "Reply with the single word: ok",
role: "user",
},
],
});

console.log(data);
```

```bash cURL
# Request fields are the provider's own — see Input below.
curl https://api.comfy.org/v2/models/anthropic/claude-opus-4-8 \
-H "X-API-Key: $COMFY_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'
-d "{\"max_tokens\": 16, \"messages\": [{\"content\":\"Reply with the single word: ok\",\"role\":\"user\"}]}"
```
</CodeGroup>

Expand All @@ -70,7 +81,7 @@
</ParamField>

<ParamField body="messages[].content" type="object" required>
Either a string shorthand or an array of content blocks (text, image, document, tool_use, tool_result, ...).

Check warning on line 84 in development/comfy-router/models/anthropic/claude-opus-4-8/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-opus-4-8/code.mdx#L84

Did you really mean 'tool_use'?

Check warning on line 84 in development/comfy-router/models/anthropic/claude-opus-4-8/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-opus-4-8/code.mdx#L84

Did you really mean 'tool_result'?
</ParamField>

<ParamField body="messages[].role" type="string" required>
Expand Down
19 changes: 15 additions & 4 deletions development/comfy-router/models/anthropic/claude-opus-5/code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
result = client.models.run(
"anthropic/claude-opus-5",
{
# Request fields are the provider's own — see Input below.
"max_tokens": 16,
"messages": [
{
"content": "Reply with the single word: ok",
"role": "user",
},
],
},
)

Expand All @@ -41,19 +47,24 @@
// Reads COMFY_API_KEY from the environment. Each call sends a fresh
// Idempotency-Key and waits up to 10 minutes for the finished result.
const { data } = await comfy.models.run("anthropic/claude-opus-5", {
// Request fields are the provider's own — see Input below.
max_tokens: 16,
messages: [
{
content: "Reply with the single word: ok",
role: "user",
},
],
});

console.log(data);
```

```bash cURL
# Request fields are the provider's own — see Input below.
curl https://api.comfy.org/v2/models/anthropic/claude-opus-5 \
-H "X-API-Key: $COMFY_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'
-d "{\"max_tokens\": 16, \"messages\": [{\"content\":\"Reply with the single word: ok\",\"role\":\"user\"}]}"
```
</CodeGroup>

Expand All @@ -70,7 +81,7 @@
</ParamField>

<ParamField body="messages[].content" type="object" required>
Either a string shorthand or an array of content blocks (text, image, document, tool_use, tool_result, ...).

Check warning on line 84 in development/comfy-router/models/anthropic/claude-opus-5/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-opus-5/code.mdx#L84

Did you really mean 'tool_use'?

Check warning on line 84 in development/comfy-router/models/anthropic/claude-opus-5/code.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dripart) - vale-spellcheck

development/comfy-router/models/anthropic/claude-opus-5/code.mdx#L84

Did you really mean 'tool_result'?
</ParamField>

<ParamField body="messages[].role" type="string" required>
Expand Down
Loading
Loading