OpenAI Integration

Use Turing Dock with ChatGPT, Assistants, and the Agents SDK.

ChatGPT GPT Actions

Add Turing Dock as a GPT Action so your custom GPT can check balances, make payments, and list transactions. Import the OpenAPI spec directly:

https://turingdock.com/openapi.json

1. Go to chatgpt.com → Explore GPTs → Create

2. Under Actions, click Import from URL and paste the OpenAPI URL above

3. Set authentication to API Key with Bearer scheme, and enter your td_live_... key

4. Save and your GPT can now make payments through Turing Dock

SDK + OpenAI Agents SDK

Use the Turing Dock TypeScript SDK directly in your OpenAI agent. Works with the Agents SDK, Assistants API, or any custom agent framework.

import { TuringDock } from "@turingdock/sdk";
import OpenAI from "openai";

const dock = new TuringDock({
  apiKey: process.env.TURINGDOCK_API_KEY!,
});

const openai = new OpenAI();

// Define Turing Dock tools for your agent
const tools = [
  {
    type: "function",
    function: {
      name: "check_balance",
      description: "Check the dock's current balance",
      parameters: { type: "object", properties: {} },
    },
  },
  {
    type: "function",
    function: {
      name: "make_payment",
      description: "Make a payment from the dock",
      parameters: {
        type: "object",
        properties: {
          to: { type: "string", description: "Recipient dock ID" },
          amountCents: { type: "integer", description: "Amount in cents" },
          memo: { type: "string", description: "Payment memo" },
        },
        required: ["to", "amountCents"],
      },
    },
  },
];

// Handle tool calls in your agent loop
async function handleToolCall(name, args) {
  if (name === "check_balance") {
    return await dock.getBalance();
  }
  if (name === "make_payment") {
    return await dock.pay(args);
  }
}

Function Definitions

Copy these function definitions into your OpenAI Assistants or function calling setup.

get_balance

Get the current balance of the dock

Parameters
{
  "type": "object",
  "properties": {},
  "required": []
}
Implementation
async function get_balance() {
  const res = await fetch("https://api.turingdock.com/pay", {
    headers: {
      "Authorization": "Bearer " + process.env.TURINGDOCK_API_KEY
    }
  });
  // Use the dock info endpoint for balance
  const dock = await fetch("https://api.turingdock.com/docks/me", {
    headers: {
      "Authorization": "Bearer " + process.env.TURINGDOCK_API_KEY
    }
  });
  return await dock.json();
}

make_payment

Make a dock-to-dock payment

Parameters
{
  "type": "object",
  "properties": {
    "to": {
      "type": "string",
      "description": "Recipient dock ID"
    },
    "amount_cents": {
      "type": "integer",
      "description": "Amount in cents"
    },
    "memo": {
      "type": "string",
      "description": "Optional payment memo"
    }
  },
  "required": ["to", "amount_cents"]
}
Implementation
async function make_payment(to, amount_cents, memo) {
  const res = await fetch("https://api.turingdock.com/pay", {
    method: "POST",
    headers: {
      "Authorization": "Bearer " + process.env.TURINGDOCK_API_KEY,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      to,
      amountCents: amount_cents,
      memo
    })
  });
  return await res.json();
}

list_transactions

List recent transactions for the dock

Parameters
{
  "type": "object",
  "properties": {
    "limit": {
      "type": "integer",
      "description": "Max results (default 20)"
    }
  },
  "required": []
}
Implementation
async function list_transactions(limit = 20) {
  const res = await fetch(
    "https://api.turingdock.com/transactions?limit=" + limit,
    {
      headers: {
        "Authorization": "Bearer " + process.env.TURINGDOCK_API_KEY
      }
    }
  );
  return await res.json();
}