How It Works

  1. Replace the import - Change from openai to @openfiles-ai/sdk/openai
  2. Add your OpenFiles key - Include your OpenFiles API key
  3. That’s it - Your AI can now create and manage files automatically

Features

  • 100% OpenAI Compatible - All OpenAI features still work
  • Automatic File Operations - No manual tool handling
  • Zero Learning Curve - Use your existing OpenAI knowledge
  • TypeScript & Python - Full support for both

Installation

Refer to the SDK Overview for installation instructions.

Two Simple Changes

// 1. Change the import
import OpenAI from '@openfiles-ai/sdk/openai' // ← Changed from 'openai'

const ai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,        // ← Same as before
  openFilesApiKey: process.env.OPENFILES_API_KEY // ← Add this line
})

// Everything else stays exactly the same
const response = await ai.chat.completions.create({
  model: 'gpt-4',
  messages: [{
    role: 'user',
    content: 'Create a shopping list for making chocolate chip cookies and save it as shopping-list.md'
  }]
})

console.log(response.choices[0].message.content)
// "I've created a shopping list with all the ingredients 
// you'll need for chocolate chip cookies..."

What Gets Added

When you use our OpenAI replacement, we automatically:
  1. Inject file operation tools into your requests
  2. Execute file operations when the AI calls them
  3. Return results seamlessly to the AI
  4. Continue the conversation naturally

Supported Operations

Your AI can automatically:
  • Create files - “Write a grocery list for tonight’s dinner party”
  • Read files - “What’s in my shopping-list.md file?”
  • Edit files - “Add butter to the shopping list”
  • List files - “Show me all my recipe files”
  • Append content - “Add a new item to my todo list”
  • Overwrite files - “Replace my old travel itinerary”
  • Get metadata - “How large is the vacation-photos.txt?”
  • Access versions - “Show me previous versions of my budget spreadsheet”

File Organization

Use basePath to organize files:
const ai = new OpenAI({
  apiKey: 'sk-...',
  openFilesApiKey: 'oa-...',
  basePath: 'projects/website'
})
// All files created under 'projects/website/'

Monitoring

Add callbacks to monitor file operations:
const ai = new OpenAI({
  apiKey: 'sk-...',
  openFilesApiKey: 'oa-...',
  onFileOperation: (op) => {
    console.log(`File operation: ${op.action} ${op.path}`)
  }
})

Compatibility

  • ✅ Chat completions (text-based conversations)
  • ✅ All OpenAI chat models (GPT-3.5, GPT-4, etc.)
  • ✅ Function calling and tool use
  • 🔜 Streaming responses (coming soon)
  • 🔜 Image inputs and vision models (coming soon)
  • 🔜 Assistants API (coming soon)

When to Use OpenAI Integration

Choose OpenAI Integration when:
  • You’re already using the OpenAI SDK
  • You want the simplest possible setup
  • You need automatic file operations with zero configuration
  • You prefer a drop-in replacement approach
Consider alternatives:
  • Tools Integration - If you’re using multiple AI providers or want more control
  • Core Client - If you need direct API access without AI dependencies

Next Steps