Skip to content
OpenSmartRoute
Skillv1.0.0

clade-migration-deep-dive

Migrate from OpenAI/GPT to Anthropic/Claude — API differences, Use when working with migration-deep-dive patterns. prompt adaptation, SDK swap, and feature mapping. Trigger with "migrate to claude", "

by jeremylongshore(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from jeremylongshore/tons-of-skills-marketplace (skills/.curated/clade-migration-deep-dive/SKILL.md). Install upstream with npx skills add jeremylongshore/tons-of-skills-marketplace --skill clade-migration-deep-dive. Copyright stays with the author (MIT).

Migrate from OpenAI to Anthropic

Overview

Migrate from OpenAI/GPT to Anthropic/Claude. Covers the complete API mapping (endpoints, models, response shapes), SDK swap with before/after code, five key differences (max_tokens required, system as top-level param, alternating messages, response path, streaming events), and tool use migration.

API Mapping

OpenAI Anthropic Notes
openai.chat.completions.create() anthropic.messages.create() Different request/response shape
model: 'gpt-4o' model: 'claude-sonnet-4-20250514' Different model IDs
response.choices[0].message.content response.content[0].text Different response path
system in messages array system as separate parameter Claude uses top-level system
response_format: { type: 'json_object' } System prompt: "Respond in JSON only" No native JSON mode
tools / function_calling tools (similar but different schema) Input schema differences
openai.embeddings.create() N/A — use Voyage or Cohere No embeddings API

SDK Swap

Instructions

Step 1: Before (OpenAI)

import OpenAI from 'openai';
const openai = new OpenAI();

const response = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [
    { role: 'system', content: 'You are helpful.' },
    { role: 'user', content: 'Hello' },
  ],
});
console.log(response.choices[0].message.content);

Step 2: After (Anthropic)

import Anthropic from '@claude-ai/sdk';
const anthropic = new Anthropic();

const response = await anthropic.messages.create({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 1024, // Required (not optional like OpenAI)
  system: 'You are helpful.', // Separate from messages
  messages: [
    { role: 'user', content: 'Hello' },
  ],
});
console.log(response.content[0].text);

Key Differences

  1. max_tokens is required — OpenAI defaults it, Anthropic requires it
  2. system is a top-level param — not a message in the array
  3. First message must be user — can't start with assistant
  4. Messages must alternate — no two user or two assistant messages in a row
  5. Response shapecontent[0].text not choices[0].message.content
  6. Streaming events — different event types and structure

Tool Use Migration

// OpenAI tool definition
{ type: 'function', function: { name: 'get_weather', parameters: { ... } } }

// Anthropic tool definition
{ name: 'get_weather', input_schema: { ... } }  // Flatter structure

Grep & Replace

# Find all OpenAI imports
grep -rn "from 'openai'" --include="*.ts" .
grep -rn "import OpenAI" --include="*.ts" .

# Find response access patterns to update
grep -rn "choices\[0\]" --include="*.ts" .
grep -rn "message.content" --include="*.ts" .  # May need updating

Output

  • All openai imports replaced with @claude-ai/sdk
  • Response access patterns updated (choices[0].message.contentcontent[0].text)
  • System prompts moved from messages array to top-level system parameter
  • max_tokens added to all API calls (required, not optional)
  • Tool definitions restructured to Anthropic format

Error Handling

Error Cause Solution
API Error Check error type and status code See clade-common-errors

Examples

See API Mapping table, Before/After SDK code, Key Differences list, Tool Use Migration, and Grep & Replace commands above.

Resources

Next Steps

See clade-sdk-patterns for production Anthropic SDK patterns.

Prerequisites

  • Existing OpenAI integration to migrate
  • Access to codebase with search capability
  • Test suite for comparing outputs between providers

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/jeremylongshore-tons-of-skills-marketplace-clade-migrati-da6b25/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

jeremylongshore-tons-of-skills-marketplace-clade-migrati-da6b25.ocm.jsonjson
{
  "ocm": "1",
  "id": "jeremylongshore-tons-of-skills-marketplace-clade-migrati-da6b25",
  "kind": "skill",
  "name": "clade-migration-deep-dive",
  "description": "Migrate from OpenAI/GPT to Anthropic/Claude — API differences, Use when working with migration-deep-dive patterns. prompt adaptation, SDK swap, and feature mapping. Trigger with \"migrate to claude\", \"openai to anthropic\", \"switch from gpt to claude\", \"replace openai with anthropic\".",
  "publisher": "jeremylongshore",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "saas",
      "anthropic",
      "claude",
      "migration",
      "openai",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Migrate from OpenAI/GPT to Anthropic/Claude — API differences, Use when working with migration-deep-dive patterns. prompt adaptation, SDK swap, and feature mapping. Trigger with \"migrate to claude\", \"openai to anthropic\", \"switch from gpt to claude\", \"replace openai with anthropic\"."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/jeremylongshore/tons-of-skills-marketplace",
      "path": "skills/.curated/clade-migration-deep-dive/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/HEAD/skills/.curated/clade-migration-deep-dive/SKILL.md",
      "key": "jeremylongshore/tons-of-skills-marketplace/skills/.curated/clade-migration-deep-dive/SKILL.md"
    },
    "compatibility": "Designed for Claude Code",
    "allowed_tools": [
      "Read,",
      "Write,",
      "Edit,",
      "Grep"
    ],
    "license": "MIT"
  },
  "instructions": "# Migrate from OpenAI to Anthropic\n\n## Overview\n\nMigrate from OpenAI/GPT to Anthropic/Claude. Covers the complete API mapping (endpoints, models, response shapes), SDK swap with before/after code, five key differences (max_tokens required, system as top-level param, alternating messages, response path, streaming events), and tool use migration.\n\n## API Mapping\n\n| OpenAI | Anthropic | Notes |\n|--------|-----------|-------|\n| `openai.chat.completions.create()` | `anthropic.messages.create()` | Different request/response shape |\n| `model: 'gpt-4o'` | `model: 'claude-sonnet-4-20250514'` | Differen",
  "cost": {
    "context_tokens": 982
  }
}

Fetch it by URL: GET /api/v1/registry/jeremylongshore-tons-of-skills-marketplace-clade-migrati-da6b25/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.