Inference
DigitalOcean runs models two ways. Serverless Inference calls a model by name on shared GPUs, with an OpenAI-compatible API, billed per token. Dedicated Inference serves an open-weight model from Hugging Face on GPUs reserved for you, at its own endpoint, billed by the hour whether or not you call it.
- models
- mistral-3-14B · qwen3-embedding-0.6b · …
- model
- Mistral-7B-Instruct-v0.3
- GPU
- 1 × H100
Call a model by name
Section titled “Call a model by name”Serverless Inference authenticates with a model access key, which you create in the control panel under GenAI Platform → Serverless Inference; DigitalOcean has no API to create one. Pass it to the binding:
import * as DigitalOcean from "@alchemy.run/digitalocean";import * as Config from "effect/Config";import * as Effect from "effect/Effect";import * as HttpServerResponse from "effect/http/HttpServerResponse";
export default class Api extends DigitalOcean.App<Api>()( "Api", { main: import.meta.url }, Effect.gen(function* () { const key = yield* Config.Redacted("DO_MODEL_KEY"); const chat = yield* DigitalOcean.Inference.CreateChatCompletion({ key }); return { fetch: Effect.gen(function* () { const out = yield* chat({ model: "mistral-3-14B", messages: [{ role: "user", content: "Say hello" }], }); return HttpServerResponse.text(out.choices[0]?.message?.content ?? ""); }).pipe(Effect.orDie), }; }).pipe(Effect.provide(DigitalOcean.Inference.CreateChatCompletionHttp)),) {}The key reaches the App as a secret.
Other kinds of model
Section titled “Other kinds of model”Each kind of call has its own binding, all taking the same { key }:
CreateEmbeddingturns text into vectors, for search in a vector database.CreateResponseandCreateMessagespeak the OpenAI Responses and Anthropic Messages formats.CreateImage,CreateSpeechandCreateVideogenerate media;GetVideoandGetVideoContentfetch a finished video.ListModelslists the catalog.
Run many requests as a batch
Section titled “Run many requests as a batch”A batch runs a file of requests at a lower price, finishing within a day:
const upload = yield* DigitalOcean.Inference.CreateBatchFile({ key });const createBatch = yield* DigitalOcean.Inference.CreateBatch({ key });const getBatch = yield* DigitalOcean.Inference.GetBatch({ key });GetBatchResults reads the answers once getBatch reports the batch completed; CancelBatch stops one.
Serve your own model
Section titled “Serve your own model”const vpcId = "<your region's default VPC id>";const llm = yield* DigitalOcean.Inference.DedicatedInference("Llm", { region: "tor1", vpcId, publicEndpoint: true, models: [ { model: "mistralai/Mistral-7B-Instruct-v0.3", accelerators: [{ gpu: "gpu-h100x1-80gb" }], }, ],});Deploy waits while the GPUs start and the weights load, ten to thirty minutes. llm.publicEndpoint serves /v1/chat/completions, and llm.token authorizes calls to it. Without publicEndpoint, it answers only inside its VPC.
CustomModel imports a model from Hugging Face or a Spaces bucket to serve the same way.
Limits
Section titled “Limits”- Dedicated Inference is offered in a few regions (
tor1,ric1,atl1,nyc2), and a GPU plan can be out of capacity there. Deploy then fails with “The selected GPU Plan … is currently unavailable in this region”. - A dedicated endpoint bills by the hour for its GPUs from create to destroy, whether or not it serves requests.