finds.dev← search

// the find

567-labs/instructor-js

★ 801 · TypeScript · MIT · updated Jan 2025

structured extraction for llms

instructor-js wraps the OpenAI client (and compatible providers) to make structured extraction from LLMs a first-class TypeScript operation: define a Zod schema, pass it as `response_model`, get back a typed object. It's the TypeScript port of the Python instructor library, built on top of the Island AI toolkit for streaming JSON parsing.

Partial streaming support is genuinely useful — you get incrementally hydrated typed objects as the model generates, not just a final blob. The Zod integration is tight: `.describe()` on fields propagates into the prompt automatically, and you can attach `.refine()` validators that trigger auto-retry loops. Provider abstraction is decent — switching between OpenAI, Anyscale, Together, and via llm-polyglot to Anthropic requires changing one line. The retry logic on schema validation failures is baked in (`max_retries`), which is the thing everyone reimplements manually otherwise.

Last push was January 2025 and the repo is under a new org slug (`567-labs`) with 801 stars — compare this to the Python sibling which is orders of magnitude more active; the JS version feels like a secondary concern. Anthropic support goes through a third-party adapter (`llm-polyglot`) rather than being native, which is a leaky abstraction when Anthropic changes its API. The test suite hits real provider APIs (see `tests/anthropic.test.ts`, `tests/google.test.ts`) with no obvious mock layer, making CI expensive and flaky without real keys. Documentation examples still reference `gpt-3.5-turbo` and `claude-3-opus-20240229` — both outdated — which signals how stale the maintenance cadence is.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →