OpenAI Integration
Use Turing Dock with ChatGPT, Assistants, and the Agents SDK.
Try the Turing Dock Agent GPT
See it in action — our demo GPT can check balances, retrieve card details, make payments, and list transactions. Open it in ChatGPT to try it out.
ChatGPT GPT Actions
Build your own GPT with Turing Dock actions. Import the agent OpenAPI spec to give your GPT access to balance checks, payments, card details, and transaction history:
https://www.turingdock.com/openapi-agent.json1. Go to chatgpt.com/gpts/editor
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
{
"type": "object",
"properties": {},
"required": []
}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
{
"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"]
}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
{
"type": "object",
"properties": {
"limit": {
"type": "integer",
"description": "Max results (default 20)"
}
},
"required": []
}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();
}