Implementation:Openai Openai node Assistants Resource
| Knowledge Sources | |
|---|---|
| Domains | SDK, Assistants, Beta |
| Last Updated | 2026-02-15 12:00 GMT |
Overview
The Assistants resource class provides deprecated beta methods to create, retrieve, update, list, and delete OpenAI Assistants via the Assistants v2 API.
Description
The Assistants class extends APIResource and exposes five CRUD methods -- create, retrieve, update, list, and delete -- that map to the /assistants REST endpoints. Every method injects the OpenAI-Beta: assistants=v2 header automatically. All methods are marked @deprecated because the Assistants API has been superseded by the Responses API.
The file also defines the core Assistant interface representing a persisted assistant object, including properties such as id, model, name, instructions, tools, tool_resources, metadata, temperature, and top_p. Tools are typed as a union of CodeInterpreterTool, FileSearchTool, and FunctionTool.
Additionally, the file exports extensive streaming event types (AssistantStreamEvent, RunStreamEvent, RunStepStreamEvent, MessageStreamEvent, ThreadStreamEvent) used to model server-sent events during assistant run streaming. The parameter interfaces AssistantCreateParams, AssistantUpdateParams, and AssistantListParams define the accepted input shapes for creating, updating, and listing assistants respectively.
Usage
Use this resource when working with the deprecated Assistants v2 beta API. Access it via client.beta.assistants. For new projects, the Responses API is recommended instead.
Code Reference
Source Location
- Repository: openai-node
- File: src/resources/beta/assistants.ts
Signature
export class Assistants extends APIResource {
/** @deprecated */
create(body: AssistantCreateParams, options?: RequestOptions): APIPromise<Assistant>;
/** @deprecated */
retrieve(assistantID: string, options?: RequestOptions): APIPromise<Assistant>;
/** @deprecated */
update(assistantID: string, body: AssistantUpdateParams, options?: RequestOptions): APIPromise<Assistant>;
/** @deprecated */
list(
query?: AssistantListParams | null | undefined,
options?: RequestOptions,
): PagePromise<AssistantsPage, Assistant>;
/** @deprecated */
delete(assistantID: string, options?: RequestOptions): APIPromise<AssistantDeleted>;
}
Import
import OpenAI from 'openai';
// Access via client.beta.assistants
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| model | Shared.ChatModel | Yes | The model ID to use for the assistant |
| name | null | No | The name of the assistant (max 256 characters) |
| description | null | No | The description (max 512 characters) |
| instructions | null | No | System instructions (max 256,000 characters) |
| tools | Array<AssistantTool> |
No | Tools enabled on the assistant (max 128) |
| tool_resources | null | No | Resources used by the assistant's tools |
| metadata | null | No | Up to 16 key-value pairs |
| temperature | null | No | Sampling temperature between 0 and 2 |
| top_p | null | No | Nucleus sampling parameter |
| response_format | null | No | Output format constraint |
| reasoning_effort | null | No | Reasoning effort for reasoning models |
Outputs
| Name | Type | Description |
|---|---|---|
| Assistant | Assistant |
The assistant object with id, model, name, tools, metadata, etc. |
| AssistantDeleted | AssistantDeleted |
Confirmation object with id, deleted boolean, and object type |
| AssistantsPage | CursorPage<Assistant> |
Paginated list of assistant objects |
Usage Examples
Basic Usage
import OpenAI from 'openai';
const client = new OpenAI();
// Create an assistant
const assistant = await client.beta.assistants.create({
model: 'gpt-4o',
name: 'Math Tutor',
instructions: 'You are a helpful math tutor.',
tools: [{ type: 'code_interpreter' }],
});
// List assistants
const page = await client.beta.assistants.list({ limit: 10 });
// Retrieve a specific assistant
const retrieved = await client.beta.assistants.retrieve(assistant.id);
// Update an assistant
const updated = await client.beta.assistants.update(assistant.id, {
name: 'Advanced Math Tutor',
});
// Delete an assistant
const deleted = await client.beta.assistants.delete(assistant.id);