structured-output
Skill4 starsChanged 3 months agoMITView on GitHub
Use Interfaze AI to produce strict JSON or schema-constrained structured objects from any prompt. Activate when the user needs typed, machine-readable output — JSON objects, arrays, validated fields, or Zod/Pydantic-style extraction. Use this when the task requires a specific output shape, data normalization, or converting unstructured text into structured records, even if the user just says "give me this as JSON" or "parse this into fields."
- Reads credentials
- Installs packages
5 other projects use a version of this.
Adopted by
Most recently taken up by
- nahid-sparktales/agent-dispatchertheir own version, first seen Sep 21, 2026
- LingXi-Org/LingxiSkillstheir own version, first seen Aug 17, 2026
- nimadorostkar/Claude-Skills-collectiontheir own version, first seen Jul 14, 2026
- Archive228/loopkittheir own version, first seen Jun 29, 2026
- mykaarma/kaarma-skillstheir own version, first seen Apr 28, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- Archive228/loopkit★ 756same name
- nahid-sparktales/agent-dispatcher★ 59same name
- nimadorostkar/Claude-Skills-collection★ 28same name
- mykaarma/kaarma-skills★ 4same name
- LingXi-Org/LingxiSkills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- object-detectionSkill
- ocrSkill
- speech-to-textSkill
- web-scrapingSkill
- web-searchSkill
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 3 are distinctive, and 8 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 41
Keep the schema root an object.
- Very specific: line 47
Every SDK reads the API key from INTERFAZE_API_KEY.
- Distinctive: line 61
No base URL or model name to configure — both are built in.
- Very specific: line 265
Use .nullable() (Zod) or Optional[T] = None (Pydantic) for fields that may not be present.
- Very specific: line 266
Use .describe() (Zod) or Field(description=...) (Pydantic) to clarify ambiguous fields — the model reads these descriptions.
- Distinctive: line 267
Keep schemas focused. Prefer multiple targeted calls over one massive schema.
- Distinctive: line 275
Use when a field may not exist in the source data.
- Very specific: line 295
Use .describe() (Zod) or Field(description=...) (Pydantic) when the field name alone is ambiguous — the model reads these.
- Very specific: line 351
Interfaze SDK (Python): read response.choices[0].message.parsed.
- Very specific: line 357
When Interfaze runs a task to answer the request — OCR, web search, transcription — the raw output of that task comes back as precontext …
- Very specific: line 380
Use streamText with partialOutputStream (Vercel AI SDK) or interfaze.stream(...) (LangChain) when you want partial objects as they are …
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Structured Output with Interfaze AI
Generate outputs into strict, schema-validated JSON using Zod (TypeScript) or Pydantic (Python) schemas.
When to use this skill
- The user needs output in a specific JSON shape or typed format
- The task requires extracting structured fields from unstructured text
- The user says "give me JSON", "parse this into an object", "extract these fields"
- You need to validate AI output against a schema before using it downstream
- The output will be consumed by code, not displayed to a human
When not to use this skill
- The user wants free-form text, summaries, or conversational responses
- The input is an image that needs OCR first → use
ocr, then apply structured output - The input is audio → use
speech-to-textfirst, then apply structured output if needed
Workflow
- Identify the target output shape from the user's request.
- Define a Zod (TypeScript) or Pydantic (Python) schema matching the expected structure.
- Pass the schema via the SDK's structured-output mechanism:
- Interfaze SDK:
responseFormat(z.toJSONSchema(Schema), "name")(TS) orcompletions.parse(response_format=Model)(Python) - Vercel AI SDK:
generateText({ output: Output.object({ schema }) }) - LangChain SDK:
withStructuredOutput/with_structured_output
- Interfaze SDK:
Rules that affect every schema
- Keep the schema root an
object. A non-object root gets wrapped under aresultkey. - With the Interfaze SDK in TypeScript and the OpenAI SDK,
message.contentcomes back as a JSON string — parse it. The Pythonparse()helper, Vercel AI SDK, and LangChain all hand back a decoded object. strictdefaults tofalse. Interfaze follows the OpenAI structured output specification.
Setup
Every SDK reads the API key from INTERFAZE_API_KEY.
TypeScript — Interfaze SDK
npm install interfazeimport { Interfaze } from "interfaze";
const interfaze = new Interfaze();No base URL or model name to configure — both are built in.
TypeScript — Vercel AI SDK
npm install ai @ai-sdk/openaiimport { createOpenAI } from "@ai-sdk/openai";
const interfaze = createOpenAI({
baseURL: "https://api.interfaze.ai/v1",
apiKey: process.env.INTERFAZE_API_KEY,
});Requires ai@^7.0.0 and @ai-sdk/openai@^4.0.0.
TypeScript — LangChain SDK
npm install @interfaze-ai/langchainimport { ChatInterfaze } from "@interfaze-ai/langchain";
const interfaze = new ChatInterfaze({ apiKey: process.env.INTERFAZE_API_KEY });Python — Interfaze SDK
pip install interfazefrom interfaze import Interfaze
interfaze = Interfaze()Python — LangChain SDK
pip install interfaze-langchainimport os
from interfaze_langchain import ChatInterfaze
interfaze = ChatInterfaze(api_key=os.environ["INTERFAZE_API_KEY"])Already using the OpenAI SDK?
Point an existing OpenAI client at Interfaze and pass model: "interfaze" on every call. Use zodResponseFormat(Schema, "schema_name") from openai/helpers/zod in TypeScript, or a json_schema response format built from Model.model_json_schema() in Python.
import OpenAI from "openai";
const interfaze = new OpenAI({
baseURL: "https://api.interfaze.ai/v1",
apiKey: process.env.INTERFAZE_API_KEY,
});from openai import OpenAI
interfaze = OpenAI(base_url="https://api.interfaze.ai/v1", api_key="<your-api-key>")Example: generate a structured object from a prompt
TypeScript — Interfaze SDK
import { responseFormat } from "interfaze";
import { z } from "zod";
const CodeSchema = z.object({
code: z.string(),
sample_input: z.string(),
sample_output: z.string(),
});
const response = await interfaze.chat.completions.create({
messages: [
{ role: "user", content: "Write a Python script to check CPU type using subprocess." },
],
response_format: responseFormat(z.toJSONSchema(CodeSchema), "code_schema"),
});
console.log(JSON.parse(response.choices[0]?.message.content ?? "{}"));TypeScript — Vercel AI SDK
import { generateText, Output } from "ai";
import { z } from "zod";
const CodeSchema = z.object({
code: z.string(),
sample_input: z.string(),
sample_output: z.string(),
});
const { output } = await generateText({
model: interfaze.chat("interfaze"),
output: Output.object({ schema: CodeSchema }),
prompt: "Write a Python script to check CPU type using subprocess.",
});
console.log(output);TypeScript — LangChain SDK
import { z } from "zod";
const CodeSchema = z.object({
code: z.string(),
sample_input: z.string(),
sample_output: z.string(),
});
const structuredModel = interfaze.withStructuredOutput(CodeSchema);
const response = await structuredModel.invoke(
"Write a Python script to check CPU type using subprocess."
);
console.log(response);Python — Interfaze SDK
from pydantic import BaseModel
class CodeSchema(BaseModel):
code: str
sample_input: str
sample_output: str
response = interfaze.chat.completions.parse(
messages=[
{"role": "user", "content": "Write a Python script to check CPU type using subprocess."},
],
response_format=CodeSchema,
)
print(response.choices[0].message.parsed)Python — LangChain SDK
from pydantic import BaseModel
class CodeSchema(BaseModel):
code: str
sample_input: str
sample_output: str
structured_llm = interfaze.with_structured_output(CodeSchema)
response = structured_llm.invoke("Write a Python script to check CPU type using subprocess.")
print(response)Example: array of structured objects
Wrap the list in an object rather than using an array at the root.
const LanguagesSchema = z.object({
languages: z.array(
z.object({
name: z.string(),
rank: z.number(),
primary_use_case: z.string(),
})
),
});class Language(BaseModel):
name: str
rank: int
primary_use_case: str
class LanguagesSchema(BaseModel):
languages: list[Language]Schema design tips
- Use
.nullable()(Zod) orOptional[T] = None(Pydantic) for fields that may not be present. - Use
.describe()(Zod) orField(description=...)(Pydantic) to clarify ambiguous fields — the model reads these descriptions. - Keep schemas focused. Prefer multiple targeted calls over one massive schema.
Schema patterns
Basic objects and arrays are shown above. Other common shapes:
Nullable fields
Use when a field may not exist in the source data.
z.object({
name: z.string(),
email: z.string().nullable(),
phone: z.string().nullable(),
})from typing import Optional
class Contact(BaseModel):
name: str
email: Optional[str] = None
phone: Optional[str] = NoneDescribed fields
Use .describe() (Zod) or Field(description=...) (Pydantic) when the field name alone is ambiguous — the model reads these.
z.object({
items: z.array(z.object({ name: z.string(), price: z.string() })),
highlighted_items: z.array(
z.object({ name: z.string(), price: z.string() })
).describe("items that are visually highlighted or marked in the source"),
})from pydantic import Field
class Item(BaseModel):
name: str
price: str
class ReceiptSchema(BaseModel):
items: list[Item]
highlighted_items: list[Item] = Field(
..., description="items that are visually highlighted or marked in the source"
)Nested coordinates (spatial extraction)
z.object({
text_in_original_language: z.string(),
bounds: z.array(
z.object({
top_left_x: z.number(),
top_left_y: z.number(),
bottom_right_x: z.number(),
bottom_right_y: z.number(),
})
).describe("bounding box for each line"),
})from pydantic import Field
class Bound(BaseModel):
top_left_x: float
top_left_y: float
bottom_right_x: float
bottom_right_y: float
class SpatialSchema(BaseModel):
text_in_original_language: str
bounds: list[Bound] = Field(..., description="bounding box for each line")Response handling
- Interfaze SDK (TS): parse
response.choices[0].message.content. - Interfaze SDK (Python): read
response.choices[0].message.parsed. - Vercel AI SDK: destructure
outputfromgenerateText. - LangChain SDK: the call returns the typed object directly. Pass
includeRaw: true/include_raw=Trueto get{ parsed, raw }instead.
Reading precontext alongside your schema
When Interfaze runs a task to answer the request — OCR, web search, transcription — the raw output of that task comes back as precontext next to your structured object. Use it for confidence scores, bounding boxes, timestamps, and source URLs.
// Interfaze SDK
response.precontext?.[0]?.result;
// Vercel AI SDK — untyped, read off the raw body
// @ts-expect-error precontext is not typed
response.body?.precontext;
// LangChain SDK — requires includeRaw
response.raw.response_metadata.precontext;# Interfaze SDK
response.precontext[0].result if response.precontext else None
# LangChain SDK — requires include_raw=True
response["raw"].response_metadata.get("precontext")Streaming structured output
Use streamText with partialOutputStream (Vercel AI SDK) or interfaze.stream(...) (LangChain) when you want partial objects as they are produced.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

