co-mono/todos/done/20250817-183528-ai-unified-api-package.md
Mario Zechner f064ea0e14 feat(ai): Create unified AI package with OpenAI, Anthropic, and Gemini support
- Set up @mariozechner/ai package structure following monorepo patterns
- Install OpenAI, Anthropic, and Google Gemini SDK dependencies
- Document comprehensive API investigation for all three providers
- Design minimal unified API with streaming-first architecture
- Add models.dev integration for pricing and capabilities
- Implement automatic caching strategy for all providers
- Update project documentation with package creation guide
2025-08-17 20:18:45 +02:00

2.6 KiB

Create AI Package with Unified API

Status: Done Agent PID: 10965

Original Todo

ai: create a new package ai (package name @mariozechner/ai) which implements a common api for the openai, anthropic, and google gemini apis - look at the other packages and how they are set up, mirror that setup for ai - install the latest version of each dependency via npm in the ai package - openai@5.12.2 - @anthropic-ai/sdk@0.60.0 - @google/genai@1.14.0 - investigate the APIs in their respective node_modules folder so you understand how to use them. specifically, we need to understand how to: - stream responses, including reasoning/thinking tokens and tool calls - abort requests - handle errors - handle stop reasons - maintain the context (message history) such that it can be serialized in a uniform format to disk, and deserialized again later and used with the other api - count tokens (input, output, cached read, cached write) - enable caching - Create a plan.md in the ai package that details how the unified API on top of all three could look like. we want the most minimal api possible, which allows serialization/deserialization, turning on/off reasoning/thinking, and handle system prompt and tool specifications

Description

Create the initial package scaffold for @mariozechner/ai following the established monorepo patterns, install the required dependencies (openai, anthropic, google genai SDKs), and create a plan.md file that details the unified API design for all three providers.

Read analysis.md in full for detailed codebase research and context

Implementation Plan

  • Create package directory structure at packages/ai/
  • Create package.json with proper configuration following monorepo patterns
  • Create tsconfig.build.json for build configuration
  • Create initial src/index.ts file
  • Add package to root tsconfig.json path mappings
  • Update root package.json build script to include ai package
  • Install dependencies: openai@5.12.2, @anthropic-ai/sdk@0.60.0, @google/genai@1.14.0
  • Create README.md with package description
  • Create plan.md detailing the unified API design
  • Investigate OpenAI, Anthropic, and Gemini APIs in detail
  • Document implementation details for each API
  • Update todos/project-description.md with "How to Create a New Package" section
  • Update todos/project-description.md Testing section to reflect that tui has Node.js built-in tests
  • Run npm install from root to link everything
  • Verify package builds correctly with npm run build

Notes

[Implementation notes]