agentleFS
InterfazeAIInterfazeAI/interfaze-skills/skills/ocr/SKILL.md

ocr

Skill4 starsChanged 3 months agoMITView on GitHub

Use Interfaze AI for OCR and visual text extraction from images, screenshots, scans, PDFs, invoices, receipts, IDs, forms, menus, and labels with complex layouts. Activate when the user wants to extract text, fields, or structured data from an image or scanned document — even if they say "read this", "what does this say", or "pull the data from this photo" without mentioning OCR.

  • Reads credentials
  • Installs packages

5 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions5 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 5

    1. OpenCoven/coven★ 67same name
    2. Gonglitian/agent-skills★ 2same name
    3. hec-ovi/ocr-skill★ 1same name
    4. Shugar86/my-agent★ 0same name
    5. stardustai/stardust-skills★ 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.

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every SDK reads the API key from INTERFAZE_API_KEY.

    line 41
  2. Distinctive:

    No base URL or model name to configure — both are built in.

    line 55
  3. Very specific:

    Use .describe() / Field(description=...) when a field name alone is ambiguous.

    line 368
  4. Distinctive:

    Run OCR on its own to get a fixed output shape with line-level bounding boxes and per-word confidence, skipping the full model.

    line 375

“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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

OCR — Visual OCR with Interfaze AI

Extract text and structured fields from images and scanned documents using Interfaze AI's vision OCR capability.

When to use this skill

  • The user has an image, screenshot, scan, or photo and wants text extracted from it
  • The input is a receipt, invoice, ID card, form, menu, or label captured as an image
  • The user wants structured fields (name, address, totals, line items) pulled from a visual source
  • The user says "read this image", "extract the text", "what does this receipt say"
  • The task involves layout-aware extraction where text position matters

When not to use this skill

  • The input is a native text file, JSON, or CSV — no vision needed
  • The user wants to transcribe audio → use speech-to-text
  • The task is locating objects without reading text → use object-detection
  • The user wants to convert existing data to a schema → use structured-output
  • The user wants to pull data from a live URL → use web-scraping

Workflow

  1. Confirm the input is an image URL, PDF URL, or base64-encoded file.
  2. Decide whether you need plain text or structured fields.
  3. For structured fields, define a Zod (TS) or Pydantic (Python) schema.
  4. Pass the file in the message content array using the SDK's file/image part.
  5. Match the SDK and language to the user's project.

Setup

Every SDK reads the API key from INTERFAZE_API_KEY.

TypeScript — Interfaze SDK

npm install interfaze
import { 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/openai
import { 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/langchain
import { ChatInterfaze } from "@interfaze-ai/langchain";

const interfaze = new ChatInterfaze({ apiKey: process.env.INTERFAZE_API_KEY });

Python — Interfaze SDK

pip install interfaze
from interfaze import Interfaze

interfaze = Interfaze()

Python — LangChain SDK

pip install interfaze-langchain
import os
from interfaze_langchain import ChatInterfaze

interfaze = ChatInterfaze(api_key=os.environ["INTERFAZE_API_KEY"])

Already using the OpenAI SDK?

Interfaze supports the Chat Completion API standard, so point an existing OpenAI client at it and pass model: "interfaze" on every call.

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>")

Input formats

Supported sources: public HTTPS URLs and base64 data URLs.

SDKImage partPDF / document part
Interfaze / LangChain (TS & Py){ type: "image_url", image_url: { url: "<url>" } }{ type: "file", file: { filename: "doc.pdf", file_data: "<url-or-base64>" } }
Vercel AI SDK{ type: "image", mediaType: "image/jpeg", image: "<url-or-base64>" }{ type: "file", data: "<url>", mediaType: "application/pdf" }

Size limits: 20 MB as a file part, 80 MB when the URL is written directly into the prompt text. For large documents, put the URL in the prompt instead — the model fetches it at inference time.

Example: extract fields from an ID card

TypeScript — Interfaze SDK

import { responseFormat } from "interfaze";
import { z } from "zod";

const IDSchema = z.object({
  first_name: z.string().describe("First name on the ID"),
  last_name: z.string().describe("Last name on the ID"),
  dob: z.string().describe("Date of birth on the ID"),
  driver_licence_number: z.string().describe("Driver licence number on the ID"),
});

const response = await interfaze.chat.completions.create({
  messages: [
    {
      role: "user",
      content: [
        { type: "text", text: "Extract the details from this ID" },
        { type: "image_url", image_url: { url: "https://example.com/id.jpg" } },
      ],
    },
  ],
  response_format: responseFormat(z.toJSONSchema(IDSchema), "id_schema"),
});

console.log(JSON.parse(response.choices[0]?.message.content ?? "{}"));
console.log("OCR Results:", response.precontext?.[0]?.result);

TypeScript — Vercel AI SDK

import { generateText, Output } from "ai";
import { z } from "zod";

const IDSchema = z.object({
  first_name: z.string().describe("First name on the ID"),
  last_name: z.string().describe("Last name on the ID"),
  dob: z.string().describe("Date of birth on the ID"),
  driver_licence_number: z.string().describe("Driver licence number on the ID"),
});

const { output, response } = await generateText({
  model: interfaze.chat("interfaze"),
  output: Output.object({ schema: IDSchema }),
  messages: [
    {
      role: "user",
      content: [
        { type: "text", text: "Extract the details from this ID" },
        { type: "image", mediaType: "image/jpeg", image: "https://example.com/id.jpg" },
      ],
    },
  ],
});

console.log(output);

// @ts-expect-error precontext is not typed
console.log("OCR Results:", response.body?.precontext?.[0]?.result);

TypeScript — LangChain SDK

import { z } from "zod";

const IDSchema = z.object({
  first_name: z.string().describe("First name on the ID"),
  last_name: z.string().describe("Last name on the ID"),
  dob: z.string().describe("Date of birth on the ID"),
  driver_licence_number: z.string().describe("Driver licence number on the ID"),
});

const structuredModel = interfaze.withStructuredOutput(IDSchema, { includeRaw: true });

const response = await structuredModel.invoke([
  {
    role: "user",
    content: [
      { type: "text", text: "Extract the details from this ID" },
      { type: "image_url", image_url: { url: "https://example.com/id.jpg" } },
    ],
  },
]);

console.log(response.parsed);
console.log("OCR Results:", response.raw.response_metadata.precontext?.[0]?.result);

Python — Interfaze SDK

from pydantic import BaseModel, Field

class IDSchema(BaseModel):
    first_name: str = Field(..., description="First name on the ID")
    last_name: str = Field(..., description="Last name on the ID")
    dob: str = Field(..., description="Date of birth on the ID")
    driver_licence_number: str = Field(..., description="Driver licence number on the ID")

response = interfaze.chat.completions.parse(
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Extract the details from this ID"},
                {"type": "image_url", "image_url": {"url": "https://example.com/id.jpg"}},
            ],
        }
    ],
    response_format=IDSchema,
)

print(response.choices[0].message.parsed)
print("OCR Results:", response.precontext[0].result if response.precontext else None)

Python — LangChain SDK

from langchain_core.messages import HumanMessage
from pydantic import BaseModel, Field

class IDSchema(BaseModel):
    first_name: str = Field(..., description="First name on the ID")
    last_name: str = Field(..., description="Last name on the ID")
    dob: str = Field(..., description="Date of birth on the ID")
    driver_licence_number: str = Field(..., description="Driver licence number on the ID")

structured_llm = interfaze.with_structured_output(IDSchema, include_raw=True)

response = structured_llm.invoke([
    HumanMessage(content=[
        {"type": "text", "text": "Extract the details from this ID"},
        {"type": "image_url", "image_url": {"url": "https://example.com/id.jpg"}},
    ])
])

print(response["parsed"])
print("OCR Results:", response["raw"].response_metadata.get("precontext"))

Example: receipt line items

Same call as the ID card above — only the schema changes.

const ReceiptSchema = z.object({
  items: z.array(z.object({ name: z.string(), price: z.string() })),
  total_cost: z.string(),
  tax: z.string(),
});
class ReceiptItem(BaseModel):
    name: str
    price: str

class ReceiptSchema(BaseModel):
    items: list[ReceiptItem]
    total_cost: str
    tax: str

Example: PDF document

Swap the image part for a file part. The call is otherwise identical to the ID card example.

{
  type: "file",
  file: { filename: "research-paper.pdf", file_data: "https://arxiv.org/pdf/1706.03762" },
}
{
    "type": "file",
    "file": {"filename": "research-paper.pdf", "file_data": "https://arxiv.org/pdf/1706.03762"},
}

For the Vercel AI SDK, use { type: "file", data: "<url>", mediaType: "application/pdf" }.

Plain text (no schema)

Drop the response_format / output argument when you only need raw text.

import { generateText } from "ai";

const { text } = await generateText({
  model: interfaze.chat("interfaze"),
  messages: [
    {
      role: "user",
      content: [
        { type: "text", text: "Extract all text from this image" },
        { type: "image", image: "https://example.com/scan.jpg" },
      ],
    },
  ],
});

Reading local files

The Interfaze SDK's inputs helpers read a local file or raw bytes and build the content part.

import { inputs } from "interfaze";

inputs.image(await inputs.fromPath("./photo.png"));
inputs.file(await inputs.dataUrl(pdfBytes, "application/pdf"), { filename: "report.pdf" });
from interfaze import inputs

inputs.image(inputs.from_path("./photo.png"))
inputs.file(inputs.data_url(pdf_bytes, "application/pdf"), filename="report.pdf")

Tips

  • Use .describe() / Field(description=...) when a field name alone is ambiguous.
  • For multilingual text, name the target language in the prompt or field descriptions. 100+ languages, including mixed-language documents, are supported.
  • For layout-aware extraction, include coordinate fields in your schema.
  • The model corrects and normalizes text in the structured output. precontext holds the uncorrected raw OCR, which is what you want for auditing or confidence thresholds.

Advanced: raw OCR output & bounding boxes

Run OCR on its own to get a fixed output shape with line-level bounding boxes and per-word confidence, skipping the full model. This is faster and cheaper than a schema-driven call.

TypeScript — Interfaze SDK

const result = await interfaze.tasks.ocr("https://example.com/id.jpg");

console.log(result);

TypeScript — Vercel AI SDK

import { generateText, Output } from "ai";

const { output } = await generateText({
  model: interfaze.chat("interfaze"),
  system: "<task>ocr</task>",
  output: Output.json(),
  messages: [
    {
      role: "user",
      content: [
        { type: "text", text: "Extract all text from this ID" },
        { type: "image", mediaType: "image/jpeg", image: "https://example.com/id.jpg" },
      ],
    },
  ],
});

console.log(output);

TypeScript — LangChain SDK

import { HumanMessage, SystemMessage } from "@langchain/core/messages";

const response = await interfaze.invoke([
  new SystemMessage("<task>ocr</task>"),
  new HumanMessage({
    content: [
      { type: "text", text: "Extract all text from this ID" },
      { type: "image_url", image_url: { url: "https://example.com/id.jpg" } },
    ],
  }),
]);

const { result } = JSON.parse(response.content as string);
console.log(result);

Python — Interfaze SDK

result = interfaze.tasks.ocr("https://example.com/id.jpg")

print(result)

Python — LangChain SDK

import json
from langchain_core.messages import HumanMessage, SystemMessage

response = interfaze.invoke([
    SystemMessage(content="<task>ocr</task>"),
    HumanMessage(content=[
        {"type": "text", "text": "Extract all text from this ID"},
        {"type": "image_url", "image_url": {"url": "https://example.com/id.jpg"}},
    ]),
])

print(json.loads(response.content).get("result"))

Task mode rules: only one <task> runs per request, and the response format must be an empty or any schema — passing a real schema alongside a task returns a 400.

The result shape:

{
  "name": "ocr",
  "result": {
    "extracted_text": "California\nUSA\nDRIVER LICENSE\n...",
    "sections": [
      {
        "text": "California\nUSA\n...",
        "lines": [
          {
            "text": "California",
            "bounds": {
              "top_left": { "x": 63, "y": 89 },
              "bottom_right": { "x": 268, "y": 129 },
              "width": 205,
              "height": 40
            },
            "average_confidence": 0.99,
            "words": [{ "text": "California", "confidence": 0.99, "bounds": {} }]
          }
        ]
      }
    ],
    "width": 698,
    "height": 525
  }
}

The same data is available on precontext for normal (non-task) calls, alongside your schema output.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.