← Back to comparisons

CoFounder vs OpenAI SDK

The OpenAI SDK is great for OpenAI models. CoFounder gives you the same experience across all providers, plus production features you actually need.

5+
Providers Supported
1
Unified API
Auto
Tool Execution
Built-in
Fallbacks
FeatureOpenAI SDKCoFounder
OpenAI Models
Both support all OpenAI models
Anthropic Models
CoFounder supports Claude models natively
Google Models
CoFounder supports Gemini models
Local Models (Ollama)
CoFounder supports local models out of the box
Unified API
One API for all providers
Automatic Tool Execution
CoFounder runs tools automatically
Cost Tracking
CoFounder tracks costs across providers
Built-in Testing
CoFounder includes testing utilities
Automatic Fallbacks
CoFounder falls back between providers
Security Features
CoFounder includes injection detection, PII filtering

Basic Chat Completion

OpenAI SDK15 lines
import OpenAI from 'openai';

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

const completion = await openai.chat.completions.create({
  model: 'gpt-4',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'Hello!' },
  ],
});

console.log(completion.choices[0].message.content);
CoFounder9 lines
import { createCoFounder } from '@aicofounder/core';

const cofounder = createCoFounder();

const response = await cofounder
  .system('You are a helpful assistant.')
  .chat('Hello!');

console.log(response.content);

Multi-Provider Support

OpenAI SDK19 lines
// OpenAI SDK - only supports OpenAI
import OpenAI from 'openai';
import Anthropic from '@anthropic-ai/sdk';

// Need separate clients for each provider
const openai = new OpenAI();
const anthropic = new Anthropic();

// Different APIs for each
const openaiResponse = await openai.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello' }],
});

const anthropicResponse = await anthropic.messages.create({
  model: 'claude-3-sonnet-20240229',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Hello' }],
});
CoFounder15 lines
import { createCoFounder } from '@aicofounder/core';

const cofounder = createCoFounder();

// Same API for all providers
const gpt4 = await cofounder.model('gpt-4').chat('Hello');

const claude = await cofounder.model('claude-3-sonnet').chat('Hello');

const gemini = await cofounder.model('gemini-pro').chat('Hello');

// Switch providers with one line
const response = await cofounder
  .model(process.env.MODEL || 'gpt-4')
  .chat('Hello');

Tool Calling

OpenAI SDK36 lines
import OpenAI from 'openai';

const openai = new OpenAI();

const tools = [
  {
    type: 'function',
    function: {
      name: 'get_weather',
      description: 'Get the weather in a location',
      parameters: {
        type: 'object',
        properties: {
          location: {
            type: 'string',
            description: 'The city name',
          },
        },
        required: ['location'],
      },
    },
  },
];

const completion = await openai.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Weather in SF?' }],
  tools,
});

// Manually handle tool calls
const toolCall = completion.choices[0].message.tool_calls?.[0];
if (toolCall) {
  const args = JSON.parse(toolCall.function.arguments);
  // Execute function, make another API call...
}
CoFounder20 lines
import { createCoFounder, createTool } from '@aicofounder/core';

const cofounder = createCoFounder();

const weather = createTool({
  name: 'get_weather',
  description: 'Get the weather in a location',
  parameters: { location: { type: 'string' } },
  handler: async ({ location }) => {
    return `Weather in ${location}: Sunny, 72°F`;
  },
});

// CoFounder automatically executes tools
const response = await cofounder
  .tools([weather])
  .chat('Weather in SF?');

// Response includes the result directly
console.log(response.content);

Streaming

OpenAI SDK16 lines
import OpenAI from 'openai';

const openai = new OpenAI();

const stream = await openai.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Tell a story' }],
  stream: true,
});

for await (const chunk of stream) {
  const content = chunk.choices[0]?.delta?.content;
  if (content) {
    process.stdout.write(content);
  }
}
CoFounder7 lines
import { createCoFounder } from '@aicofounder/core';

const cofounder = createCoFounder();

for await (const chunk of cofounder.stream('Tell a story')) {
  process.stdout.write(chunk);
}

The Multi-Provider Advantage

Automatic Fallbacks

If OpenAI is down, automatically switch to Anthropic or Google. Zero downtime, zero code changes.

Cost Optimization

Route simple queries to cheaper models automatically. Use GPT-4 only when needed.

Best Model Selection

Different models excel at different tasks. Use Claude for analysis, GPT-4 for code, Gemini for multimodal.

When to Choose Each

Choose CoFounder if you:

  • Want flexibility to use multiple providers
  • Need automatic fallbacks and reliability
  • Want built-in cost tracking and testing
  • Prefer cleaner, simpler APIs

Choose OpenAI SDK if you:

  • Only ever need OpenAI models
  • Need direct access to OpenAI-specific features
  • Have existing code using OpenAI SDK