Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions specification/DigitalOcean-public.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3981,6 +3981,23 @@ paths:
post:
$ref: 'resources/inference/inference_async_invoke.yml'


/v1/audio/speech:
post:
$ref: 'resources/inference/inference_create_speech.yml'

/v1/videos:
post:
$ref: 'resources/inference/inference_create_video.yml'

/v1/videos/{video_id}:
get:
$ref: 'resources/inference/inference_get_video.yml'

/v1/videos/{video_id}/content:
get:
$ref: 'resources/inference/inference_get_video_content.yml'

/v1/batches/files:
post:
$ref: 'resources/inference/inference_create_batch_file.yml'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
lang: cURL
source: |-
curl -sS https://inference.do-ai.run/v1/audio/speech \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-tts-voicedesign",
"input": "Hello, world!",
"voice": "alloy",
"response_format": "mp3",
"instructions": "Speak naturally."
}' \
--output output.mp3
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
lang: cURL
source: |-
curl -X POST https://inference.do-ai.run/v1/videos \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2-2-t2v-a14b",
"prompt": "Two anthropomorphic cats in boxing gear fight intensely on a spotlighted stage",
"size": "1280x720",
"fps": 16
}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
lang: cURL
source: |-
curl https://inference.do-ai.run/v1/videos/$VIDEO_ID \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
lang: cURL
source: |-
curl https://inference.do-ai.run/v1/videos/$VIDEO_ID/content \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
--output output.mp4
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
lang: JavaScript
source: |-
import { writeFileSync } from "fs";
import { InferenceClient } from "@digitalocean/dots";
const client = new InferenceClient({
apiKey: process.env.DIGITALOCEAN_TOKEN,
});
const response = await client.audio.speech.create({
model: "qwen3-tts-voicedesign",
input: "Hello, world!",
voice: "alloy",
response_format: "mp3",
instructions: "Speak naturally.",
});
const audioBytes = Buffer.from(response.data[0].b64_json, "base64");
writeFileSync("output.mp3", audioBytes);
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
lang: JavaScript
source: |-
import { InferenceClient } from "@digitalocean/dots";
const client = new InferenceClient({
apiKey: process.env.DIGITALOCEAN_TOKEN,
});
const job = await client.video.generations.create({
model: "wan2-2-t2v-a14b",
prompt: "Two anthropomorphic cats in boxing gear fight intensely on a spotlighted stage",
size: "1280x720",
fps: 16,
});
console.log(job.id, job.status);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
lang: JavaScript
source: |-
import { InferenceClient } from "@digitalocean/dots";
const client = new InferenceClient({
apiKey: process.env.DIGITALOCEAN_TOKEN,
});
const job = await client.video.generations.retrieve(process.env.VIDEO_ID);
console.log(job.id, job.status);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
lang: JavaScript
source: |-
import { writeFileSync } from "fs";
import { InferenceClient } from "@digitalocean/dots";
const client = new InferenceClient({
apiKey: process.env.DIGITALOCEAN_TOKEN,
});
const content = await client.video.generations.content(process.env.VIDEO_ID);
writeFileSync("output.mp4", Buffer.from(await content.arrayBuffer()));
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ source: |-
}
if msg := completion.Choices[0].Message.Content; msg != nil {
fmt.Println(*msg)
fmt.Println(msg.Text())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ source: |-
}
if msg := completion.Choices[0].Message.Content; msg != nil {
fmt.Println(*msg)
fmt.Println(msg.Text())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
lang: Go
label: Knowledge base
source: |-
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/digitalocean/godo"
)
func main() {
client := godo.NewFromToken(os.Getenv("DIGITALOCEAN_TOKEN"))
ctx := context.Background()
completion, _, err := client.Chat.Completions.New(ctx, &godo.ChatCompletionNewParams{
Model: "openai-gpt-oss-20b",
Messages: []godo.ChatCompletionMessage{
godo.UserMessage("What are some features of DigitalOcean Inference?"),
},
Tools: []godo.ChatCompletionTool{
godo.ChatKnowledgeBaseRetrievalTool(os.Getenv("KNOWLEDGE_BASE_ID")),
},
ToolChoice: json.RawMessage(`"auto"`),
MaxTokens: godo.PtrTo(1024),
})
if err != nil {
panic(err)
}
if msg := completion.Choices[0].Message.Content; msg != nil {
fmt.Println(msg.Text())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
lang: Go
label: MCP tool
source: |-
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/digitalocean/godo"
)
func main() {
client := godo.NewFromToken(os.Getenv("DIGITALOCEAN_TOKEN"))
ctx := context.Background()
completion, _, err := client.Chat.Completions.New(ctx, &godo.ChatCompletionNewParams{
Model: "openai-gpt-oss-20b",
Messages: []godo.ChatCompletionMessage{
godo.UserMessage("Fetch my DigitalOcean account information and summarize it in 2 bullets."),
},
Tools: []godo.ChatCompletionTool{
godo.ChatMCPTool(godo.MCPToolParams{
ServerLabel: "digitalocean",
ServerURL: "https://accounts.mcp.digitalocean.com/mcp",
Authorization: "Bearer " + os.Getenv("DIGITALOCEAN_API_TOKEN"),
AllowedTools: []string{"account-get-information"},
}),
},
ToolChoice: json.RawMessage(`"required"`),
MaxTokens: godo.PtrTo(512),
})
if err != nil {
panic(err)
}
if msg := completion.Choices[0].Message.Content; msg != nil {
fmt.Println(msg.Text())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
lang: Go
label: Vision (VLM)
source: |-
package main
import (
"context"
"fmt"
"os"
"github.com/digitalocean/godo"
)
func main() {
client := godo.NewFromToken(os.Getenv("DIGITALOCEAN_TOKEN"))
ctx := context.Background()
// IMAGE_URL may be an HTTPS URL or a data:image/...;base64,... URI.
imageURL := os.Getenv("IMAGE_URL")
if imageURL == "" {
imageURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Online_Bicycles.jpg/640px-Online_Bicycles.jpg"
}
completion, _, err := client.Chat.Completions.New(ctx, &godo.ChatCompletionNewParams{
Model: "nemotron-nano-12b-v2-vl",
Messages: []godo.ChatCompletionMessage{
godo.UserMessageParts(
godo.TextPart("Describe this image."),
godo.ImageURLPart(imageURL),
),
},
MaxTokens: godo.PtrTo(512),
})
if err != nil {
panic(err)
}
if msg := completion.Choices[0].Message.Content; msg != nil {
fmt.Println(msg.Text())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
lang: Go
label: Model synthesis
source: |-
package main
import (
"context"
"fmt"
"os"
"github.com/digitalocean/godo"
)
func main() {
client := godo.NewFromToken(os.Getenv("DIGITALOCEAN_TOKEN"))
ctx := context.Background()
resp, _, err := client.Responses.New(ctx, &godo.ResponseNewParams{
Model: "openai-gpt-oss-20b",
Input: "Compare approaches for reducing inference latency.",
Tools: []godo.ResponseTool{
godo.ModelSynthesisTool(godo.ModelSynthesisToolParams{
Preset: "balanced",
}),
},
MaxOutputTokens: godo.PtrTo(1024),
})
if err != nil {
panic(err)
}
fmt.Println(resp.OutputText())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
lang: Go
label: Tool search
source: |-
package main
import (
"context"
"fmt"
"os"
"github.com/digitalocean/godo"
)
func main() {
client := godo.NewFromToken(os.Getenv("DIGITALOCEAN_TOKEN"))
ctx := context.Background()
resp, _, err := client.Responses.New(ctx, &godo.ResponseNewParams{
Model: "openai-gpt-5.5",
Input: "Compare the current weather in zip code 94107 and 10001.",
Tools: []godo.ResponseTool{
godo.FunctionTool("get_weather", "Get weather for a zip code", map[string]interface{}{
"type": "object",
"properties": map[string]interface{}{
"zip": map[string]interface{}{"type": "string"},
},
"required": []string{"zip"},
}),
godo.ToolSearchTool(),
},
MaxOutputTokens: godo.PtrTo(1024),
})
if err != nil {
panic(err)
}
fmt.Println(resp.OutputText())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
lang: Go
label: Web fetch
source: |-
package main
import (
"context"
"fmt"
"os"
"github.com/digitalocean/godo"
)
func main() {
client := godo.NewFromToken(os.Getenv("DIGITALOCEAN_TOKEN"))
ctx := context.Background()
resp, _, err := client.Responses.New(ctx, &godo.ResponseNewParams{
Model: "openai-gpt-oss-20b",
Input: "Summarize https://www.digitalocean.com/pricing",
Tools: []godo.ResponseTool{
godo.WebFetchTool(godo.PtrTo(3)),
},
MaxOutputTokens: godo.PtrTo(1024),
})
if err != nil {
panic(err)
}
fmt.Println(resp.OutputText())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
lang: Go
label: Web search
source: |-
package main
import (
"context"
"fmt"
"os"
"github.com/digitalocean/godo"
)
func main() {
client := godo.NewFromToken(os.Getenv("DIGITALOCEAN_TOKEN"))
ctx := context.Background()
resp, _, err := client.Responses.New(ctx, &godo.ResponseNewParams{
Model: "openai-gpt-oss-20b",
Input: "What are the latest pricing changes for DigitalOcean Droplets?",
Tools: []godo.ResponseTool{
godo.WebSearchTool(godo.PtrTo(3), godo.PtrTo(5)),
},
MaxOutputTokens: godo.PtrTo(1024),
})
if err != nil {
panic(err)
}
fmt.Println(resp.OutputText())
}
Loading
Loading