Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
structured extraction for llms
| Date | Stars |
|---|---|
| 2026-07-31 | 801 |
| 2026-08-04 | 802 |
| 2026-08-06 | 802 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# instructor-js
_Structured extraction in Typescript, powered by llms, designed for simplicity, transparency, and control._
---
[](https://twitter.com/jxnlco)
[](https://twitter.com/dimitrikennedy)
[](https://www.npmjs.com/package/@instructor-ai/instructor)
[](https://jxnl.github.io/instructor-js)
[](https://github.com/instructor-ai/instructor-js/issues)
[](https://discord.gg/CV8sPM5k5Y)
Dive into the world of Typescript-based structured extraction, by OpenAI's function calling API and Zod, typeScript-first schema validation with static type inference. Instructor stands out for its simplicity, transparency, and user-centric design. Whether you're a seasoned developer or just starting out, you'll find Instructor's approach intuitive and steerable.
## Installation
```bash
bun add @instructor-ai/instructor zod openai
```
```bash
npm i @instructor-ai/instructor zod openai
```
```bash
pnpm add @instructor-ai/instructor zod openai
```
## Basic Usage
To check out all the tips and tricks to prompt and extract data, check out the [documentation](https://instructor-ai.github.io/instructor-js/tips/prompting/).
```typescript
import Instructor from "@instructor-ai/instructor";
import OpenAI from "openai"
import { z } from "zod"
const oai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY ?? undefined,
organization: process.env.OPENAI_ORG_ID ?? undefined
})
const client = Instructor({
client: oai,
mode: "TOOLS"
})
const UserSchema = z.object({
// Description will be used in the prompt
age: z.number().describe("The age of the user"),
name: z.string()
})
// User will be of type z.infer<typeof UserSchema>
const user = await client.chat.completions.create({
messages: [{ role: "user", content: "Jason Liu is 30 years old" }],
model: "gpt-3.5-turbo",
response_model: {
schema: UserSchema,
name: "User"
}
})
console.log(user)
// { age: 30, name: "Jason Liu" }
```
## API Reference
### Instructor Class
The main class for creating an Instructor client.
**createInstructor**
```typescript
function createInstructor<C extends GenericClient | OpenAI>(args: {
client: OpenAILikeClient<C>;
mode: Mode;
debug?: boolean;
}): InstructorClient<C>
```
Creates an instance of the Instructor class.
- client: An OpenAI-like client.
- mode: The mode of operation.
- debug: Whether to log debug messages.
Returns the extended OpenAI-Like client.
**chat.completions.create**
```typescript
chat.completions.create<
T extends z.AnyZodObject,
P extends T extends z.AnyZodObject ? ChatCompletionCreateParamsWithModel<T>
: ClientTypeChatCompletionParams<OpenAILikeClient<C>> & { response_model: never }
>(
params: P
): Promise<ReturnTypeBasedOnParams<typeof this.client, P>>
```
When response_model is present in the params, creates a chat completion with structured extraction based on the provided schema - otherwise will proxy back to the provided client.
- params: Chat completion parameters including the response model schema.
- Returns a promise resolving to the extracted data based on the schema.
### Modes
Instructor supports different modes for defining the structure and format of the response from the language model. These modes are defined in the `zod-stream` package and are as follows:
- `FUNCTIONS` (*DEPRECATED*): Generates a response using OpenAI's function calling API. It maps to the necessary parameters for the function calling API, including the `function_call` and `functions` properties.
- `TOOLS`: GExcerpt of 16,919 characters
Read on GitHub86
Jason Liu · OpenAI · United States
78
Sam Hogan · Inference · United States
7
4
Nipun Sadvilkar
4
3
3
3
2
2
2
2
1
1
1
1
1
1
1
swyx.io · smol.ai · United States
1
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:1a2f3cee410a9218, topic:llm