@archastro/sdk
    Preparing search index...

    Class CompletionResource

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    Methods

    • Create a chat completion Sends a list of messages to the configured AI provider and returns a single completion. Use this endpoint when you want direct, low-level access to the underlying model without any workflow or agent orchestration. The authenticated app must have the llm_calls entitlement enabled on its plan. Requests that exceed the plan quota are rejected with 402. Token usage is recorded against the authenticated app and organization. Supply tools and tool_choice to enable OpenAI-compatible function calling. Use server_tools to activate platform-managed tools such as search that run on the server side before the response is returned.

      Parameters

      • input: {
            context?: Record<string, unknown>;
            messages: {
                content?: string;
                content_parts?: Record<string, unknown>[];
                resume_token?: string;
                role: string;
                structured_output?: unknown;
                tool_calls?: {
                    arguments: Record<string, unknown>;
                    id: string;
                    name: string;
                    thought_signature?: string;
                }[];
                tool_results?: {
                    content?: string;
                    id: string;
                    name: string;
                    resolution?: unknown;
                }[];
            }[];
            opts: {
                max_tokens?: number;
                model: string;
                server_tools?: Record<string, unknown>[];
                structured_output?: Record<string, unknown>;
                temperature?: number;
                tool_choice?: string;
                tools?: {
                    function: {
                        description?: string;
                        name: string;
                        parameters: Record<string, unknown>;
                    };
                    type: string;
                }[];
            };
            session_id?: string;
        }

        Request body.

        • Optionalcontext?: Record<string, unknown>

          Key-value map used to resolve template variables in message content. Omit if messages contain no templates.

        • messages: {
              content?: string;
              content_parts?: Record<string, unknown>[];
              resume_token?: string;
              role: string;
              structured_output?: unknown;
              tool_calls?: {
                  arguments: Record<string, unknown>;
                  id: string;
                  name: string;
                  thought_signature?: string;
              }[];
              tool_results?: {
                  content?: string;
                  id: string;
                  name: string;
                  resolution?: unknown;
              }[];
          }[]

          Ordered list of conversation messages to send to the model.

        • opts: {
              max_tokens?: number;
              model: string;
              server_tools?: Record<string, unknown>[];
              structured_output?: Record<string, unknown>;
              temperature?: number;
              tool_choice?: string;
              tools?: {
                  function: {
                      description?: string;
                      name: string;
                      parameters: Record<string, unknown>;
                  };
                  type: string;
              }[];
          }

          Model and sampling configuration for this request.

        • Optionalsession_id?: string

          Optional UUID grouping this and other completions under one session in the Developers dashboard. Pass the same value across requests to link them; omit to auto-generate a per-request session.

      Returns Promise<AICompletionResult>

      The completed AI response, including the generated message, finish reason, and token usage.