Global Outreach Solutions company logo — ERP, VoIP, and custom software development in PakistanGlobal Outreach
DevOps Tutorials·8 min read

Migrating from OpenAI API to DigitalOcean's Inference

Authored by Manikandan Kurup Learn what it means for software, security, and business technology teams.

  • Ai-ml
  • Inference
  • Devops Tutorials
  • Migrating
  • From
  • Openai
  • Digitalocean

By Global Outreach

Illustrated cover image for the DevOps Tutorials article "Migrating from OpenAI API to DigitalOcean's Inference" on Global Outreach Solutions blog
  • Blog
  • Docs
  • Careers
  • Get Support
  • Contact Sales
  • Products Featured AI Products Compute Build, deploy, and scale cloud compute resources Containers and Images Safely store and manage containers and backups Managed Databases Fully managed resources running popular database engines Management and Dev Tools Control infrastructure and gather insights Networking Secure and control traffic to apps Security Help protect your account and resources with these security features Storage Store and access any amount of data reliably in the cloud Browse all products
  • Solutions AI/ML CMS Data and IoT Developer Tools Gaming and Media Hosting Security and Networking Startups and SMBs Web and App Platforms See all solutions
  • Developers Community Documentation Developer Tools Get Involved Utilities and Help
  • Partners Become a Partner Marketplace
  • Pricing
  • Log in Log in to:
  • Community
  • DigitalOcean
  • Sign up for:
  • Community
  • DigitalOcean
  • Log in Log in to:
  • Community
  • DigitalOcean
  • Sign up for:
  • Community
  • DigitalOcean
  • Tutorials
  • Questions
  • Product Docs
  • Search Community

Contents Overview

Authored by Manikandan Kurup

Position: Senior Technical Content Engineer I

DigitalOcean's Serverless Inference offers API endpoints compatible with OpenAI, allowing for easy migration of existing workflows with minor configuration updates. For basic Chat Completion requests, only the base URL, API credentials, and model ID need to be modified. Note that not all OpenAI APIs are supported, and certain features may behave differently depending on the model. This guide presents working code examples, supported endpoints, and highlights any discrepancies.

Transitioning from OpenAI to DigitalOcean Serverless Inference: Code Comparison

Here’s the initial OpenAI code snippet:

import os from openai import OpenAI client = OpenAI ( api_key = os . getenv ( "OPENAI_API_KEY" ) , ) resp = client . chat . completions . create ( model = "gpt-4o" , messages = [ { "role" : "system" , "content" : "You are a helpful assistant." } , { "role" : "user" , "content" : "Tell me a fun fact about octopuses." } , ] , ) print ( resp . choices [ 0 ] . message . content )

Here’s how the same request looks with DigitalOcean Serverless Inference:

import os from openai import OpenAI client = OpenAI ( base_url = "https://inference.do-ai.run/v1" , api_key = os . getenv ( "MODEL_ACCESS_KEY" ) , ) resp = client . chat . completions . create ( model = "llama3.3-70b-instruct" , messages = [ { "role" : "system" , "content" : "You are a helpful assistant." } , { "role" : "user" , "content" : "Tell me a fun fact about octopuses." } , ] , ) print ( resp . choices [ 0 ] . message . content )

This section highlights the differences between the two code examples:

To obtain your credentials: Navigate to the DigitalOcean Control Panel, select Inference, then Serverless Inference, and create a Model Access Key. This key differs from your OpenAI dashboard key.

Authentication for HTTP requests is done using a Bearer token. The key that changes is the credential: replace the OpenAI API key with a DigitalOcean model access key or a valid DigitalOcean personal access token.

Model IDs are unique to DigitalOcean. For example, llama3.3-70b-instruct is a DigitalOcean catalog ID rather than an OpenAI identifier. The catalog is subject to change over time. Use the GET /v1/models endpoint or check the Model Catalog in the Control Panel to avoid guessing model names. While changing the model ID maintains the API call structure, it does not guarantee that the new model will function identically to the old one; it's crucial to test output quality, context limits, and tool compatibility before deploying in production.

Request parameters may differ by model and endpoint. Do not assume that every OpenAI parameter will function identically across all models. Always refer to the latest documentation before relying on advanced parameters.

Here’s an example of streaming:

stream = client . chat . completions . create ( model = "llama3.3-70b-instruct" , messages = [ { "role" : "user" , "content" : "Write a haiku about Kubernetes." } ] , stream = True , ) for chunk in stream : if chunk . choices and chunk . choices [ 0 ] . delta . content : print ( chunk . choices [ 0 ] . delta . content , end = "" , flush = True )

Here’s the equivalent call using raw HTTP, for those not utilizing the SDK:

curl -X POST https://inference.do-ai.run/v1/chat/completions \ -H "Authorization: Bearer $MODEL_ACCESS_KEY " \ -H "Content-Type: application/json" \ -d '{ "model": "llama3.3-70b-instruct", "messages": [{"role": "user", "content": "What is the capital of France?"}], "temperature": 0.7, "max_completion_tokens": 256 }'

Which OpenAI-Compatible Endpoints Are Supported by DigitalOcean Serverless Inference?

This section focuses on the endpoints most pertinent to migrating from OpenAI, rather than providing the complete DigitalOcean API list.

A few of these endpoints require further examination.

  • Chat Completions detail: Tool support depends on the model and API surface, and the different interfaces are not interchangeable. OpenAI and Anthropic models are available through the Chat Completions and Responses APIs, but supported API surfaces vary by model. Some OpenAI models support only the Responses API for serverless inference, not Chat Completions, so check each model’s supported API surface in the Model Catalog before assuming Chat Completions will work. Anthropic models also have a separate, Anthropic-native Messages API ( client.messages.create() ) that exposes Anthropic’s own tool-use schema. DigitalOcean’s server-side tools, such as web search, knowledge base retrieval, and MCP, work with the Chat Completions and Responses APIs. A separate feature, Tool Search, lets a model load only the tool definitions it needs instead of all of them at once; it works with the Messages API for Anthropic models and the Responses API for supported OpenAI models.
  • Responses API detail: Supported features include text responses, multimodal responses, prompt caching, and reasoning in some configurations. Check tool support, reasoning, and multimodal input handling before assuming a feature works the same way it does on OpenAI.
  • Batch inference detail: Batch inference is a separate asynchronous workflow rather than a drop-in real-time endpoint. Its API accepts input files formatted for the OpenAI Batch API or the Anthropic Message Batches API, using each provider’s native format rather than converting one into the other. It uses the same base URL and model access key as real-time Serverless Inference, and it runs on separate rate limits. If you already run OpenAI or Anthropic batch jobs, DigitalOcean describes moving them here as an endpoint and authentication change, not a file-format rewrite. Limits: only text prompts on commercial OpenAI and Anthropic models, with no open-weight models, multimodal input, or image generation. OpenAI batch requests must include an endpoint field set to /v1/chat/completions or /v1/responses , matching the JSONL content; Anthropic requests skip that field. Check the batch documentation before migrating jobs.

Which OpenAI APIs Are Not Supported by DigitalOcean?

The following OpenAI endpoints do not have a compatible equivalent in the documented Serverless Inference API. Their absence from the API reference indicates a lack of compatibility, not necessarily a lack of DigitalOcean offerings.

DigitalOcean provides its own agent-building tools, including an Agent Development Kit, but these are separate products and not direct substitutes for OpenAI Assistants code.

Is DigitalOcean Serverless Inference a Complete Replacement for OpenAI?

In brief: It can serve as a near drop-in replacement for basic Chat Completions calls. However, it is not a full drop-in replacement for the OpenAI API beyond that.

For a comprehensive list of endpoints and details on requests and responses, refer to the Serverless Inference API Endpoints and the API Reference.

For a basic Chat Completions request, transitioning to DigitalOcean Serverless Inference involves three simple changes: the base URL, the credential, and the model ID. Beyond these adjustments, treat it as OpenAI-compatible in structure, but not necessarily in feature completeness. Confirm your model ID using GET /v1/models, ensure that the specific parameters, tools, and endpoints your application relies on are supported, and consult the Model Catalog and Inference Limits prior to directing production traffic.

Discover more about our offerings

Author Information

With over six years in technology publishing, Mani has edited and published more than 75 books on various data science subjects. Renowned for his meticulous attention to detail and technical expertise, Mani excels in crafting clear, concise, and easily digestible content aimed at developers.

This text box is set to use Markdown for formatting your responses.

You can use !ref in this text area to quickly search through our entire collection of tutorials, documentation, and marketplace offerings and insert the relevant link!

Highlighted Tutorials

  • All tutorials
  • All topic tags

Please fill out your information!

  • Table of contents
  • OpenAI to DigitalOcean Serverless Inference: Before and After Code
  • Which OpenAI-Compatible Endpoints Does DigitalOcean Serverless Inference Support?
  • Which OpenAI APIs Does DigitalOcean Not Support?
  • Is DigitalOcean Serverless Inference a Drop-In Replacement for OpenAI?
  • Conclusion
  • Ubuntu
  • Linux Basics
  • JavaScript
  • Python
  • MySQL
  • Docker
  • Kubernetes
  • All tutorials
  • Talk to an expert
  • Featured tutorials SOLID Design Principles Explained: Building Better Software Architecture
  • How To Remove Docker Images, Containers, and Volumes
  • How to Create a MySQL User and Grant Privileges (Step-by-Step)
  • All tutorials
  • All topic tags

Earn money by writing technical tutorials while supporting a tech-focused charity with a matching donation.

DigitalOcean Documentation

Comprehensive documentation available for all DigitalOcean products.

Resources for Startups and AI-Driven Businesses

The Wave provides essential insights on business development, from securing funding to product marketing.

The Developer Cloud

Scale your operations seamlessly, whether you manage one virtual machine or thousands.

Begin your development journey today with GPU-powered inference, Kubernetes, managed databases, and storage solutions to create, scale, and deploy intelligent applications.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

  • About
  • Leadership
  • Blog
  • Careers
  • Customers
  • Partners
  • Referral Program
  • Press
  • Legal
  • Privacy Policy
  • Security
  • Investor Relations
  • Knowledge Bases
  • GPU Droplets
  • Bare Metal GPUs
  • Inference Engine
  • Data & Learning
  • Evaluations
  • Model Library
  • Droplets
  • Kubernetes
  • Functions
  • App Platform
  • Load Balancers
  • Managed Databases
  • Spaces
  • Block Storage
  • Network File Storage
  • API
  • Uptime
  • Cloud Security Posture Management (CSPM)
  • Identity and Access Management (IAM)
  • Cloudways
  • View all Products
  • Community Tutorials
  • Community Q&A
  • CSS-Tricks
  • Currents Research
  • DigitalOcean Startups
  • Wavemakers Program
  • Compass Council
  • Open Source
  • Marketplace
  • Pricing
  • Pricing Calculator
  • Documentation
  • Release Notes
  • Code of Conduct
  • Shop Swag
  • AI Training GPU
  • GPU Inference
  • VPS Hosting
  • Website Hosting
  • VPN
  • Docker Hosting
  • Node.js Hosting
  • Web Mobile Apps
  • WordPress Hosting
  • Virtual Machines
  • View all Solutions
  • Support
  • Sales
  • Report Abuse
  • System Status
  • Share your ideas
  • About
  • Leadership
  • Blog
  • Careers
  • Customers
  • Partners
  • Referral Program
  • Press
  • Legal
  • Privacy Policy
  • Security
  • Investor Relations
  • Knowledge Bases
  • GPU Droplets
  • Bare Metal GPUs
  • Inference Engine
  • Data & Learning
  • Evaluations
  • Model Library
  • Droplets
  • Kubernetes
  • Functions
  • App Platform
  • Load Balancers
  • Managed Databases
  • Spaces
  • Block Storage
  • Network File Storage
  • API
  • Uptime
  • Cloud Security Posture Management (CSPM)
  • Identity and Access Management (IAM)
  • Cloudways
  • View all Products
  • Community Tutorials
  • Community Q&A
  • CSS-Tricks
  • Currents Research
  • DigitalOcean Startups
  • Wavemakers Program
  • Compass Council
  • Open Source
  • Marketplace
  • Pricing
  • Pricing Calculator
  • Documentation
  • Release Notes
  • Code of Conduct
  • Shop Swag
  • AI Training GPU
  • GPU Inference
  • VPS Hosting
  • Website Hosting
  • VPN
  • Docker Hosting
  • Node.js Hosting
  • Web Mobile Apps
  • WordPress Hosting
  • Virtual Machines
  • View all Solutions
  • Support
  • Sales
  • Report Abuse
  • System Status
  • Share your ideas

Want help putting this into practice?

Global Outreach builds ERP, VoIP, and custom software for businesses in Pakistan.

Start a conversation

Related articles

← All posts