Already using Anthropic? If you’re migrating from Anthropic’s API (not OpenAI), you can use the Messages API instead. It provides native Anthropic SDK compatibility—just change your base URL and API key.
Why Migrate to Heroku AI
Teams migrate to Heroku AI for several reasons:- Unified platform: Manage your AI models alongside your Heroku applications, databases, and add-ons
- Model variety: Access Claude (Anthropic), Nova (Amazon), and other models through a single API
- Simplified billing: One invoice for compute, add-ons, and AI usage
- Enterprise features: Heroku’s security, compliance, and support infrastructure
Quick Migration (5 Minutes)
For applications using the OpenAI Python or Node.js SDK, migration requires only two configuration changes:- Change the base URL from
api.openai.comtous.inference.heroku.com - Replace your OpenAI API key with your Heroku
INFERENCE_KEY
Python
- Before (OpenAI)
- After (Heroku AI)
TypeScript / Node.js
- Before (OpenAI)
- After (Heroku AI)
Environment Setup
Set up your environment variables for local development:Endpoint Mapping
Heroku AI implements the same endpoints as OpenAI:| OpenAI Endpoint | Heroku AI Endpoint | Status |
|---|---|---|
POST /v1/chat/completions | POST /v1/chat/completions | Fully compatible |
POST /v1/embeddings | POST /v1/embeddings | Fully compatible |
POST /v1/images/generations | POST /v1/images/generations | Fully compatible |
POST /v1/moderations | — | Not available |
POST /v1/audio/transcriptions | — | Not available |
POST /v1/audio/speech | — | Not available |
GET /v1/models | — | Not available |
POST /v1/files | — | Not available |
POST /v1/fine-tuning/jobs | — | Not available |
| Heroku AI Endpoint | Description |
|---|---|
POST /v1/messages | Native Anthropic Messages API for Claude (use Anthropic SDK) |
POST /v1/agents/heroku | Agentic loop with autonomous tool execution |
POST /v1/rerank | Document reranking for improved RAG |
GET /v1/mcp/servers | MCP server management |
Model Selection
Recommended Model Mappings
Choose a Heroku AI model based on your current OpenAI model and use case:| OpenAI Model | Recommended Heroku AI Model | Notes |
|---|---|---|
gpt-4o | claude-4-5-sonnet | Best general-purpose replacement |
gpt-4-turbo | claude-4-5-sonnet | Comparable capabilities |
gpt-4 | claude-4-sonnet | Strong reasoning |
gpt-3.5-turbo | claude-4-5-haiku | Fast, cost-effective |
text-embedding-3-small | cohere-embed-multilingual | 1024 dimensions |
text-embedding-3-large | cohere-embed-multilingual | Use for multilingual |
dall-e-3 | stable-image-ultra | High-quality images |
Model-Specific Considerations
Claude models (Anthropic) Claude models handle prompts slightly differently than GPT models:Choosing the Right Model
| Priority | Recommended Model | Reason |
|---|---|---|
| Lowest latency | claude-4-5-haiku | Fastest response times |
| Complex reasoning | claude-4-5-sonnet | Best for analysis, coding |
| Cost optimization | nova-lite | Good quality, lower cost |
| Extended context | claude-4-5-sonnet | 200K token context |
| Image generation | stable-image-ultra | High-quality outputs |
Feature Parity
Fully Supported Features
These OpenAI features work identically on Heroku AI:| Feature | Support Level | Notes |
|---|---|---|
| Chat completions | Full | Identical API |
| Streaming | Full | SSE format identical |
| Function calling / Tools | Full | Same schema format |
| JSON mode | Full | response_format: {"type": "json_object"} |
| System messages | Full | Identical behavior |
| Multi-turn conversations | Full | Same message format |
| Token usage reporting | Full | Same usage object |
| Temperature / top_p | Full | Same parameters |
| Stop sequences | Full | Same behavior |
| Embeddings | Full | Different model names |
Features with Differences
Some features work differently or have limitations:| Feature | Difference | Workaround |
|---|---|---|
seed parameter | Ignored | Deterministic outputs not guaranteed |
n parameter | Ignored | Generate multiple completions with separate calls |
logprobs | Not available | — |
presence_penalty | Ignored | Use prompt instructions for variety |
frequency_penalty | Ignored | Use prompt instructions for variety |
| Vision / image input | Model-dependent | Use Claude 4.5 Sonnet for vision |
n parameter:
Features Not Available
These OpenAI features are not currently available on Heroku AI:| Feature | Alternative |
|---|---|
| Fine-tuning | Use detailed system prompts and few-shot examples |
| Assistants API | Use the Agents endpoint with MCP tools |
| Audio transcription | Use a dedicated transcription service |
| Text-to-speech | Use a dedicated TTS service |
| Moderation | Implement custom content filtering |
| Batch API | Process requests sequentially with rate limiting |
Code Migration Examples
Basic Chat Completion
The simplest migration—just change configuration:- OpenAI
- Heroku AI
Streaming Responses
Streaming works identically:- OpenAI
- Heroku AI
Function Calling / Tools
Tool definitions work identically:- OpenAI
- Heroku AI
Embeddings
Embeddings use a different model name but the same API:- OpenAI
- Heroku AI
input_type parameter. Use "search_document" for content you’re indexing and "search_query" for search queries.
Environment Configuration
Local Development
Create a.env file for local development:
- Python
- Node.js
Heroku Deployment
Environment variables are set automatically when you provision a model:Multiple Environments
For staging/production parity:Testing Your Migration
Verification Checklist
After migrating, verify each functionality:- Basic chat completions work
- Streaming responses render correctly
- Function/tool calls execute properly
- Error handling catches API errors
- Rate limiting is handled gracefully
- Token usage is tracked correctly
Test Script
Run this script to verify your migration:Common Migration Issues
| Issue | Cause | Solution |
|---|---|---|
| 401 Unauthorized | Wrong API key | Use INFERENCE_KEY, not OpenAI key |
| 403 Forbidden | Wrong model | Use provisioned model from INFERENCE_MODEL_ID |
| Different output style | Model behavior | Adjust prompts for Claude/Nova specifics |
Missing n parameter | Not supported | Make multiple calls for multiple completions |
Additional Resources
- Messages API - Native Anthropic SDK for Claude models
- OpenAI SDK Compatibility - Detailed parameter support
- Models Overview - All available models
- Choosing a Model - Model selection guidance
- Error Handling - Handling API errors
- Rate Limits - Request and token limits