npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@crewai-ts/openai

v0.3.0

Published

OpenAI and OpenAI-compatible native providers for CrewAI TypeScript.

Readme

@crewai-ts/openai

npm version

OpenAI and OpenAI-compatible native providers for CrewAI TypeScript.

Provides OpenAICompletion and OpenAICompatibleCompletion with support for chat completions, responses API, built-in tools (web search, file search, code interpreter, computer use), reasoning summaries, and structured outputs.

Install

npm install @crewai-ts/openai

Requirements:

  • Node.js 22 or later
  • @crewai-ts/core 0.2.0 or later

Quick Start

import { Agent } from "@crewai-ts/core";
import { OpenAICompletion, registerOpenAIProvider } from "@crewai-ts/openai";

registerOpenAIProvider();

const agent = new Agent({
  role: "Assistant",
  goal: "Answer questions",
  backstory: "A helpful assistant.",
  llm: new OpenAICompletion({ model: "gpt-4o" }),
});

Or use the registered provider name:

const agent = new Agent({
  role: "Assistant",
  goal: "Answer questions",
  backstory: "A helpful assistant.",
  llm: "openai/gpt-4o",
});

Current Models

The provider supports gpt-6-astra, gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna, and the gpt-5.6 alias, alongside earlier models. The core model catalog and context limits include these models; the existing 85% context safety margin still applies. Existing default model choices are unchanged.

const llm = new OpenAICompletion({
  model: "gpt-6-astra",
  api: "responses",
  reasoningEffort: "high",
  maxCompletionTokens: 16000,
});

GPT-6 Astra defaults to Responses because its tool calling requires that API. Explicit api: "completions" supports text requests, but requesting tools throws an error directing you to Responses. Unsupported Astra sampling/logprobs fields are omitted, including values supplied through additionalParams. Use low, medium, high, xhigh, or max reasoning effort for Astra; none is not supported.

For reasoning Chat Completions models, maxTokens is sent as max_completion_tokens; an explicit maxCompletionTokens takes precedence. Responses uses max_output_tokens and reasoning.effort. createLLM() also preserves camelCase credentials, token limits, and reasoningEffort / reasoning_effort.

See the official model catalog and Astra migration guide.

OpenAI-Compatible Providers

OpenAICompatibleCompletion extends OpenAICompletion and is configured for a specific upstream provider via the provider option. The list of known provider keys is exported as OPENAI_COMPATIBLE_PROVIDERS.

import { OpenAICompatibleCompletion } from "@crewai-ts/openai";

// Ollama — local llama.cpp / Ollama server
const ollama = new OpenAICompatibleCompletion({
  provider: "ollama", // or "ollama_chat"
  model: "llama3.1",
  baseUrl: "http://localhost:11434/v1",
  apiKey: "ollama", // any non-empty value; Ollama ignores the key
});

// OpenRouter — hosted OpenAI-compatible routing
const openrouter = new OpenAICompatibleCompletion({
  provider: "openrouter",
  model: "anthropic/claude-3.5-sonnet",
  apiKey: process.env.OPENROUTER_API_KEY,
});

Omit provider only when you want the default openrouter config. Passing an unknown provider throws at construction time.

Built-in Tools

Enable OpenAI built-in tools:

const llm = new OpenAICompletion({
  model: "gpt-4o",
  builtinTools: ["web_search", "file_search", "code_interpreter"],
});

Responses API

Use the OpenAI Responses API:

const llm = new OpenAICompletion({
  model: "gpt-4o",
  api: "responses",
  store: true,
});

Retries and Flex Fallback

maxRetries (default 2) controls how many additional attempts are made after the first failed request — network errors and HTTP 408/409/429/5xx are retried with exponential backoff (honoring Retry-After / Retry-After-Ms response headers when present). Other errors (e.g. 400/401/404) fail immediately and are thrown as OpenAIRequestError, which preserves the HTTP status code via .status.

Set flexFallbackToAuto (or flex_fallback_to_auto) to true to fall back from service_tier: "flex" to "auto" once a retryable error occurs, so a request that starts on the cheaper Flex tier can still complete on retry instead of failing outright when Flex capacity is unavailable. Once a request falls back to "auto" it stays on "auto" for the remaining retries of that request. This defaults to false, so existing flex users are unaffected unless they opt in:

const llm = new OpenAICompletion({
  model: "gpt-4o",
  maxRetries: 3,
  additionalParams: { service_tier: "flex" },
  flexFallbackToAuto: true,
});

Exports

  • OpenAICompletion — main OpenAI provider class
  • OpenAICompatibleCompletion — OpenAI-compatible provider class
  • OpenAIRequestError — thrown on failed requests; carries the HTTP status
  • ResponsesAPIResult — responses API result wrapper
  • registerOpenAIProvider — register the provider with the core runtime
  • Result types: WebSearchResult, FileSearchResult, CodeInterpreterResult, ComputerUseResult, ReasoningSummary

License

MIT