Senior Technical Content Engineer I

DigitalOcean Serverless Inference provides OpenAI-compatible API endpoints, so many existing OpenAI SDK workflows can migrate with small configuration changes. For a basic Chat Completions call, you can keep the OpenAI Python SDK and only change the base URL, the API credential, and the model ID. Some OpenAI APIs are not supported, and some features that look the same behave differently by model. This guide shows the working code first, then the supported endpoints, the gaps, and what doesn’t carry over.
Here’s the original OpenAI code:
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 the same call using 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)
Here’s what changed between the two examples:
| Item | OpenAI | DigitalOcean Serverless Inference |
|---|---|---|
base_url |
Default (not set) | https://inference.do-ai.run/v1 |
| Credential used | OpenAI API key | DigitalOcean model access key |
| Example env variable | OPENAI_API_KEY |
MODEL_ACCESS_KEY |
| Model ID | gpt-4o |
llama3.3-70b-instruct |
| Auth scheme | Bearer token | Bearer token (unchanged) |
| SDK method used | client.chat.completions.create() |
client.chat.completions.create() (unchanged) |
| Message format | Role-based list | Role-based list (unchanged) |
Where to get the credential: In the DigitalOcean Control Panel, go to Inference, then Serverless Inference, then create a Model Access Key. This is not the same key as your OpenAI dashboard key.
The HTTP request still authenticates with a Bearer token. What changes is the credential itself: you replace the OpenAI API key with a DigitalOcean model access key or a supported DigitalOcean personal access token.
Model IDs are specific to DigitalOcean. llama3.3-70b-instruct is a DigitalOcean catalog ID, not an OpenAI name that happens to also work here, and the catalog changes over time. Call GET /v1/models or check the Model Catalog in the Control Panel instead of guessing a model name. Changing the model ID keeps the API call structure the same, but it does not make the new model behave like the old one; test output quality, context limits, and tool support before moving production workloads.
Request parameters can vary by model and endpoint. Don’t assume every OpenAI parameter behaves the same way across every model. Check the current documentation before relying on advanced parameters.
Here’s a streaming example:
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 same call as raw HTTP, if you’re not using 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
}'
This covers the endpoints most relevant to migrating from OpenAI, not DigitalOcean’s full API list.
| Endpoint | DigitalOcean path | Support level | Key compatibility note |
|---|---|---|---|
| Chat Completions | /v1/chat/completions |
Supported | Tool support depends on the model and which API surface you use. See the details below. |
| Responses API | /v1/responses |
Supported | Not every OpenAI Responses feature has a matching DigitalOcean feature. |
| Embeddings | /v1/embeddings |
Supported | Useful for semantic search and retrieval-augmented generation. |
| Image generation | /v1/images/generations |
Supported | Returns images as base64. Check the Model Catalog for which image models are currently available. |
| Batch inference | /v1/batches |
Supported, but separate | A separate asynchronous workflow, not a real-time OpenAI-compatible endpoint. You submit a job and poll for results. See the details below. |
A few of these endpoints need a closer look.
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.
These OpenAI endpoints have no OpenAI-compatible equivalent in the documented Serverless Inference API. Absence from the API reference is a statement about API compatibility, not necessarily about every DigitalOcean product.
| OpenAI API | DigitalOcean status | Notes |
|---|---|---|
| Assistants API | Not supported | No /v1/assistants endpoint. |
| Threads API | Not supported | No /v1/threads endpoint. Conversation history is not stored server-side; your application remains responsible. |
| Fine-tuning | Not supported | No /v1/fine_tuning/jobs endpoint. |
| Moderation | Not supported | No /v1/moderations endpoint. |
DigitalOcean has its own agent-building tools, including an Agent Development Kit, but they’re a separate product, not a direct replacement for OpenAI Assistants code.
Short answer: It can be close to a drop-in replacement for basic Chat Completions calls. It is not a complete drop-in replacement for the OpenAI API once you look past that.
| What changes | OpenAI | DigitalOcean Serverless Inference |
|---|---|---|
| Model IDs | OpenAI model names (e.g. gpt-4o) |
DigitalOcean catalog IDs (e.g. llama3.3-70b-instruct), listed from GET /v1/models |
| Credential | OpenAI sk- key |
DigitalOcean model access key or personal access token (sent as Bearer token) |
| Rate and usage limits | Set by OpenAI account tier | Set by DigitalOcean; can vary by account tier, model, and inference mode |
| Access to commercial models | Based on OpenAI plan | New accounts (Tier 1 and Tier 2) start with open-weight models (openai-gpt-oss-120b, openai-gpt-oss-20b); commercial models unlock at higher tiers. See Inference Limits. |
| Meaning of “OpenAI-compatible” | N/A | Describes request/response format, not a guarantee all OpenAI tools, API features, or SDK behaviors work identically |
For the full endpoint list and request and response details, see Serverless Inference API Endpoints and the API Reference.
For a basic Chat Completions call, switching to DigitalOcean Serverless Inference is a three-line change: the base URL, the credential, and the model ID. Beyond that, treat it as OpenAI-compatible in format, not in feature parity. Confirm your model ID against GET /v1/models, verify that the specific parameters, tools, and endpoints your app relies on are supported, and check the Model Catalog and Inference Limits before moving production traffic.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
With over 6 years of experience in tech publishing, Mani has edited and published more than 75 books covering a wide range of data science topics. Known for his strong attention to detail and technical knowledge, Mani specializes in creating clear, concise, and easy-to-understand content tailored for developers.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

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