Skip to content

Documentation / @agentick/openai

@agentick/openai ​

Native OpenAI adapter for Agentick.

Installation ​

bash
pnpm add @agentick/openai

Usage ​

tsx
import { openai } from "@agentick/openai";
import { createApp } from "@agentick/core";

const model = openai({ model: "gpt-4o" });

// Use with createApp
const app = createApp(MyAgent, { model });
const session = await app.session();
await session.run({ messages: [{ role: "user", content: [{ type: "text", text: "Hello!" }] }] });

// Or use as JSX component
function MyAgent() {
  return (
    <model temperature={0.9}>
      <System>You are helpful.</System>
      <Timeline />
    </model>
  );
}

// Or call directly
const result = await model.generate({
  messages: [{ role: "user", content: "Hello!" }],
});

JSX Component Pattern ​

tsx
import { OpenAIModel } from "@agentick/openai";

function MyAgent() {
  return (
    <OpenAIModel model="gpt-4o" temperature={0.7} maxTokens={4096}>
      <System>You are helpful.</System>
      <Timeline />
    </OpenAIModel>
  );
}

Azure OpenAI ​

tsx
const model = openai({
  apiKey: process.env.AZURE_OPENAI_KEY,
  baseURL: "https://your-resource.openai.azure.com",
  model: "gpt-4o",
});

Configuration ​

OptionTypeDescription
modelstringModel name (e.g., gpt-4o)
apiKeystring?OpenAI API key (env: OPENAI_API_KEY)
baseURLstring?Custom API endpoint
organizationstring?OpenAI organization ID
temperaturenumber?Sampling temperature (0-2)
maxTokensnumber?Maximum tokens to generate

Exports ​

  • openai(config) - Factory function returning ModelClass
  • createOpenAIModel(config) - Same as openai()
  • OpenAIModel - JSX component for declarative usage

Agentick OpenAI Adapter ​

Native OpenAI API adapter for Agentick. Provides direct integration with OpenAI models without requiring the Vercel AI SDK.

Features ​

  • Native API - Direct OpenAI API integration
  • Streaming - Full streaming support with deltas
  • Tool Calling - Native function calling support
  • All Models - GPT-4o, GPT-4, GPT-3.5, and more

Quick Start ​

typescript
import { openai } from '@agentick/openai';

const model = openai('gpt-4o');

// Use with app
const app = createApp(<MyAgent />);
const result = await app.run({ messages });

Classes ​

Interfaces ​

Functions ​

Released under the ISC License.