openai
Version:
The official TypeScript library for the OpenAI API
169 lines • 6.63 kB
text/typescript
import { APIResource } from "../../../../core/resource.mjs";
import { APIPromise } from "../../../../core/api-promise.mjs";
import { CursorPage, type CursorPageParams, PagePromise } from "../../../../core/pagination.mjs";
import { RequestOptions } from "../../../../internal/request-options.mjs";
import { AgentResultArtifacts } from "../../../../lib/beta/agents/result-artifacts.mjs";
import type { AgentTurnResult } from "../../../../lib/beta/agents/agent-turn-result.mjs";
export declare class Artifacts extends APIResource {
/**
* Retrieves immutable metadata for one durable session artifact. See
* [session artifacts](https://developers.openai.com/api/docs/guides/agents-api/environments/files#openai-hosted-artifacts).
*
* @example
* ```ts
* const sessionArtifact =
* await client.beta.agents.sessions.artifacts.retrieve(
* 'artifact_id',
* { session_id: 'session_id' },
* );
* ```
*/
retrieve(artifactID: string, params: ArtifactRetrieveParams, options?: RequestOptions): APIPromise<SessionArtifact>;
/**
* Lists immutable artifacts published by completed hosted session turns. See
* [session artifacts](https://developers.openai.com/api/docs/guides/agents-api/environments/files#openai-hosted-artifacts).
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const sessionArtifact of client.beta.agents.sessions.artifacts.list(
* 'session_id',
* )) {
* // ...
* }
* ```
*/
list(sessionID: string, query?: (ArtifactListParams & ({
[K in 'method' | 'path' | 'query' | 'body' | 'headers' | 'maxRetries' | 'stream' | 'timeout' | 'httpAgent' | 'fetchOptions' | 'signal' | 'idempotencyKey' | 'defaultBaseURL' | '__metadata' | '__binaryRequest' | '__binaryResponse' | '__streamClass' | '__streamMode' | '__security' | '__synthesizeEventData']?: never;
} | null | undefined)) | null | undefined, options?: RequestOptions): PagePromise<SessionArtifactsPage, SessionArtifact>;
list(sessionID: string, options?: {
[K in 'headers' | 'maxRetries' | 'timeout' | 'signal' | 'idempotencyKey' | 'query']?: RequestOptions[K];
} & {
[K in 'method' | 'path' | 'body' | 'stream' | 'httpAgent' | 'fetchOptions' | 'defaultBaseURL' | '__metadata' | '__binaryRequest' | '__binaryResponse' | '__streamClass' | '__streamMode' | '__security' | '__synthesizeEventData']?: never;
}): PagePromise<SessionArtifactsPage, SessionArtifact>;
/**
* Deletes an immutable session artifact without deleting its live environment file
* or original Files API object. See
* [session artifacts](https://developers.openai.com/api/docs/guides/agents-api/environments/files#openai-hosted-artifacts).
*
* @example
* ```ts
* const sessionArtifactDeleted =
* await client.beta.agents.sessions.artifacts.delete(
* 'artifact_id',
* { session_id: 'session_id' },
* );
* ```
*/
delete(artifactID: string, params: ArtifactDeleteParams, options?: RequestOptions): APIPromise<SessionArtifactDeleted>;
/**
* Downloads immutable session artifact bytes after the execution environment
* expires. See
* [session artifacts](https://developers.openai.com/api/docs/guides/agents-api/environments/files#openai-hosted-artifacts).
*
* @example
* ```ts
* const response =
* await client.beta.agents.sessions.artifacts.content(
* 'artifact_id',
* { session_id: 'session_id' },
* );
*
* const content = await response.blob();
* console.log(content);
* ```
*/
content(artifactID: string, params: ArtifactContentParams, options?: RequestOptions): APIPromise<Response>;
/** Beta: bind artifact lookup and downloads to a completed result's exact session and turn. */
forResult(result: AgentTurnResult): AgentResultArtifacts;
}
export type SessionArtifactsPage = CursorPage<SessionArtifact>;
/**
* An immutable file published by a completed hosted session turn.
*/
export interface SessionArtifact {
/**
* The immutable artifact ID.
*/
id: string;
/**
* The Unix timestamp, in seconds, when the artifact was published.
*/
created_at: number;
/**
* The ID of the environment that produced the artifact.
*/
environment_id: string;
/**
* The object type. Always `agent.session.artifact`.
*/
object: 'agent.session.artifact';
/**
* The original absolute file path in the execution environment.
*/
path: string;
/**
* The ID of the session that owns the artifact.
*/
session_id: string;
/**
* The immutable artifact size in bytes.
*/
size_bytes: number;
/**
* The ID of the completed turn that published the artifact.
*/
turn_id: string;
}
/**
* Confirmation that an immutable session artifact was deleted.
*/
export interface SessionArtifactDeleted {
/**
* The ID of the deleted session artifact.
*/
id: string;
/**
* Whether the session artifact was deleted. Always `true`.
*/
deleted: boolean;
/**
* The object type. Always `agent.session.artifact.deleted`.
*/
object: 'agent.session.artifact.deleted';
}
export interface ArtifactRetrieveParams {
/**
* The ID of the session that owns the artifact.
*/
session_id: string;
}
export interface ArtifactListParams extends CursorPageParams {
/**
* Restrict the listing to artifacts produced by this environment.
*/
environment_id?: string | null;
/**
* The order in which resources are returned. Defaults to `desc`.
*
* - `asc` - Returns resources in ascending order.
* - `desc` - Returns resources in descending order.
*/
order?: 'asc' | 'desc';
}
export interface ArtifactDeleteParams {
/**
* The ID of the session that owns the artifact.
*/
session_id: string;
}
export interface ArtifactContentParams {
/**
* The ID of the session that owns the artifact.
*/
session_id: string;
}
export declare namespace Artifacts {
export { type SessionArtifact as SessionArtifact, type SessionArtifactDeleted as SessionArtifactDeleted, type SessionArtifactsPage as SessionArtifactsPage, type ArtifactRetrieveParams as ArtifactRetrieveParams, type ArtifactListParams as ArtifactListParams, type ArtifactDeleteParams as ArtifactDeleteParams, type ArtifactContentParams as ArtifactContentParams, };
}
//# sourceMappingURL=artifacts.d.mts.map