Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to OpenAI

Scalekit connector
Open markdown

The OpenAI connector lets your AI agent act in each user's OpenAI account. Each user connects their own OpenAI access token once, and Scalekit sends it with every call, so your agent never handles credentials. It comes with 62 tools.

Tools
62
What they doRead · write · destructive
37 · 25 · 037 read25 write0 destructive
Users sign in with

Setup

  1. Install the SDK

    Terminal window
    npm install @scalekit-sdk/node dotenv
  2. Set your credentials

    Add your Scalekit credentials to your .env file. Find values in app.scalekit.com > Developers > API Credentials.

    .env
    SCALEKIT_ENVIRONMENT_URL=<your-environment-url>
    SCALEKIT_CLIENT_ID=<your-client-id>
    SCALEKIT_CLIENT_SECRET=<your-client-secret>
  3. Create the OpenAI connection

    In AgentKit > Connections, create an OpenAI connection. The name you give it is the connection_name your code passes. See Configure connections.

  4. Authorize a user and make your first call

    quickstart.mts
    import { ScalekitClient } from '@scalekit-sdk/node'
    import 'dotenv/config'
    import { createInterface } from 'node:readline/promises'
    const scalekit = new ScalekitClient(
    process.env.SCALEKIT_ENVIRONMENT_URL,
    process.env.SCALEKIT_CLIENT_ID,
    process.env.SCALEKIT_CLIENT_SECRET,
    )
    const actions = scalekit.actions
    const connector = 'openai'
    const identifier = 'user_123'
    // Generate an authorization link for the user
    const { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })
    console.log('Authorize OpenAI:', link)
    const rl = createInterface({ input: process.stdin, output: process.stdout })
    await rl.question('Press Enter after authorizing...')
    rl.close()
    // Make your first call
    const result = await actions.executeTool({
    connector,
    identifier,
    toolName: 'openai_batch_list',
    toolInput: {},
    })
    console.log(result)
    Terminal window
    npx tsx quickstart.mts

    Each user opens the link once and enters their OpenAI credentials there. See Authorize a user for the full flow and statuses.

Tools

Pass the exact name to execute_tool
Try in PlaygroundRequest a tool
  • openai_batch_getGet one batch job by ID.Read-only

    Get Batch

    Get one batch job by ID. Returns the batch's status (validating, in_progress, finalizing, completed, failed, expired, cancelling or cancelled), request_counts, input, output and error file IDs, errors and timestamps. Use this to poll a batch until it completes, then read its results with openai_file_content_get on output_file_id. Use openai_batch_list to find a batch ID.

    Inputs

    batch_idstringrequired
    ID of the batch. Get it from openai_batch_list or openai_batch_create. Example: batch_abc123.
  • openai_batch_listList batch jobs in the OpenAI project, newest first.Read-only

    List Batches

    List batch jobs in the OpenAI project, newest first. Returns a page of batch objects with id, endpoint, status, input_file_id, output_file_id, error_file_id, request_counts and timestamps, plus first_id, last_id and has_more. Use this to find a batch or review batch progress. Use openai_batch_get for one known batch.

    Inputs

    afterstring
    Pagination cursor: the ID of the last batch on the previous page (the last_id value of the previous response). Returns the batchs that come after it. Leave empty to start from the first page. Example: batch_abc123.
    limitinteger
    Maximum number of batches to return in one page, from 1 to 100. Leave empty to use the OpenAI default of 20. Example: 20.
  • openai_chat_completion_getGet one stored Chat Completion by ID.Read-only

    Get Stored Chat Completion

    Get one stored Chat Completion by ID. Returns the completion with id, model, created, choices (each with the assistant message and finish_reason), usage and metadata. Use this to review a completion's output. Only completions created with store set to true can be fetched; use openai_chat_completion_list to find IDs.

    Inputs

    completion_idstringrequired
    ID of the stored chat completion. Get it from openai_chat_completion_list. Example: chatcmpl-abc123.
  • openai_chat_completion_listList Chat Completions that were stored with store set to true, optionally only those from one model.Read-only

    List Stored Chat Completions

    List Chat Completions that were stored with store set to true, optionally only those from one model. Returns a page of chat completions with id, model, created, choices, usage and metadata, plus first_id, last_id and has_more. Use this to review or audit past completions. Use openai_chat_completion_get for one completion and openai_chat_completion_message_list for its messages.

    Inputs

    afterstring
    Pagination cursor: the ID of the last chat completion on the previous page (the last_id value of the previous response). Returns the chat completions that come after it. Leave empty to start from the first page. Example: chatcmpl-abc123.
    limitinteger
    Maximum number of chat completions to return in one page, from 1 to 100. Leave empty to use the OpenAI default of 20. Example: 20.
    modelstring
    Only return completions generated by this model. Example: gpt-4o-mini.
    orderstring
    Sort order by created_at: asc for oldest first, desc for newest first. Leave empty for the OpenAI default (asc). Example: desc.one of ascdesc
  • openai_chat_completion_message_listList the input messages of a stored Chat Completion.Read-only

    List Stored Chat Completion Messages

    List the input messages of a stored Chat Completion. Returns a page of messages with id, role and content, plus first_id, last_id and has_more. Use this to see the prompt behind a stored completion. Use openai_chat_completion_get for its output.

    Inputs

    completion_idstringrequired
    ID of the stored chat completion. Get it from openai_chat_completion_list. Example: chatcmpl-abc123.
    afterstring
    Pagination cursor: the ID of the last message on the previous page (the last_id value of the previous response). Returns the messages that come after it. Leave empty to start from the first page. Example: chatcmpl-abc123-0.
    limitinteger
    Maximum number of messages to return in one page, from 1 to 100. Leave empty to use the OpenAI default of 20. Example: 20.
    orderstring
    Sort order by created_at: asc for oldest first, desc for newest first. Leave empty for the OpenAI default (asc). Example: desc.one of ascdesc
  • openai_container_file_content_getDownload the raw contents of one file in a code interpreter container.Read-only

    Get Container File Content

    Download the raw contents of one file in a code interpreter container. Returns the file body as stored, such as CSV, text or image bytes. Use this to retrieve output a code interpreter run wrote, such as a chart or CSV. Use openai_container_file_get for the file's metadata only.

    Inputs

    container_idstringrequired
    ID of the container. Get it from openai_container_list. Example: cntr_682e30645a488191b6363a0cbefc0f0a.
    file_idstringrequired
    ID of the container file. Get it from openai_container_file_list. Example: cfile_682e0e8a43c88191a7978f477a09bdf5.
  • openai_container_file_getGet the metadata of one file in a code interpreter container.Read-only

    Get Container File

    Get the metadata of one file in a code interpreter container. Returns its id, container_id, path, bytes, source and created_at. Use this to check a file's path and size. Use openai_container_file_content_get to download its contents.

    Inputs

    container_idstringrequired
    ID of the container. Get it from openai_container_list. Example: cntr_682e30645a488191b6363a0cbefc0f0a.
    file_idstringrequired
    ID of the container file. Get it from openai_container_file_list. Example: cfile_682e0e8a43c88191a7978f477a09bdf5.
  • openai_container_file_listList the files in a code interpreter container, including files the code created.Read-only

    List Container Files

    List the files in a code interpreter container, including files the code created. Returns a page of container files with id, path, bytes, source and created_at, plus first_id, last_id and has_more. Use this to find files a code interpreter run produced. Use openai_container_file_content_get to download one.

    Inputs

    container_idstringrequired
    ID of the container. Get it from openai_container_list. Example: cntr_682e30645a488191b6363a0cbefc0f0a.
    afterstring
    Pagination cursor: the ID of the last container file on the previous page (the last_id value of the previous response). Returns the container files that come after it. Leave empty to start from the first page. Example: cfile_682e0e8a43c88191a7978f477a09bdf5.
    limitinteger
    Maximum number of files to return in one page, from 1 to 100. Leave empty to use the OpenAI default of 20. Example: 20.
    orderstring
    Sort order by created_at: asc for oldest first, desc for newest first. Leave empty for the OpenAI default (desc). Example: desc.one of ascdesc