Providers
OpenAI Agents SDK
Use NIN Connect tools with the OpenAI Agents SDK — Agent, run(), and function tools.
Installation
npm install @nin.in/core @openai/agents openaiEnvironment Variables
NIN_API_KEY=nk_live_xxxxxxxxx
OPENAI_API_KEY=sk-xxxxxxxxxFull Example
import { Nin } from "@nin.in/core";
import { Agent, run } from "@openai/agents";
const nin = new Nin({ apiKey: process.env.NIN_API_KEY! });
const session = nin.session("user_123");
// fetch tool definitions from the GitHub plugin
const toolDefs = await session.getTools({ plugins: ["github"] });
// build OpenAI Agents tools
// inputSchema is JSON Schema, which the OpenAI API accepts natively
const tools = toolDefs.map((t) => ({
type: "function" as const,
name: t.slug,
description: t.description,
parameters: t.inputSchema ?? { type: "object", properties: {} },
execute: async (params: Record<string, unknown>) =>
session.execute(t.slug, params),
}));
const agent = new Agent({
name: "GitHub Agent",
instructions: "You help manage GitHub repositories and issues.",
tools,
});
const result = await run(agent, "Create an issue titled 'Bug fix' in my repo");
console.log(result.finalOutput);How It Works
session.getTools()returns tool definitions withinputSchema(JSON Schema)- Tools are mapped to the OpenAI function-tool format:
{ type: "function", name, description, parameters, execute } - The
Agentis created with an instructions string and the tools array run()sends the prompt to the LLM; when the model calls a tool,executerunssession.execute()which proxies through NIN with auth injected- The agent loop continues until the model produces a final text output
Multi-Plugin Agents
You can combine tools from multiple plugins into a single agent:
const toolDefs = await session.getTools({
plugins: ["github", "slack", "gmail"],
});
const agent = new Agent({
name: "Dev Assistant",
instructions: "You help with GitHub issues, Slack messages, and emails.",
tools: toolDefs.map((t) => ({
type: "function" as const,
name: t.slug,
description: t.description,
parameters: t.inputSchema ?? { type: "object", properties: {} },
execute: async (params: Record<string, unknown>) =>
session.execute(t.slug, params),
})),
});