How to Convert Text Into Dense Vector Representations

Last verified 16 Oct 2026

Inference provides a single control plane for managing inference workflows. It includes a Model Catalog where you can view available foundation models, including both DigitalOcean-hosted and third-party commercial models, compare model capabilities and pricing, use routing to match inference requests to the best-fit model, and run inference using serverless or dedicated deployments.

Use the Embeddings API to convert text into dense vector representations for use in semantic search, retrieval-augmented generation (RAG), clustering, classification, and similarity matching. Embedding models include Qwen3 Embedding 0.6B, BGE-M3, and E5-Large. They offer a range of options across multilingual support, token window sizes, and dimensionality to match your use case.

For embedding requests, send a POST request to the https://inference.do-ai.run base URL using your existing Model Access Key. Embeddings are returned synchronously as float arrays that you can store in a vector database or use directly in your application pipeline.

The following cURL and Python PyDo examples generates a vector embedding using the Qwen3 Embedding 0.6B model:

Create a model access key and save it for use with the API.

Using PyDo, the official DigitalOcean API client for Python:

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

resp = client.embeddings.create(
    model="qwen3-embedding-0.6b",
    input=["hello world", "goodbye world"],
    encoding_format="float",
    user="user-1234",
)

for item in resp.data:
    print(item.index, item.embedding[:8])

Using Godo, the official DigitalOcean API client for Go:

package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"

    "github.com/digitalocean/godo"
)

func main() {
    client := godo.NewFromToken(os.Getenv("DIGITALOCEAN_TOKEN"))
    ctx := context.Background()

    resp, _, err := client.Embeddings.New(ctx, &godo.EmbeddingNewParams{
        Model:          "qwen3-embedding-0.6b",
        Input:          []string{"hello world", "goodbye world"},
        EncodingFormat: "float",
        User:           "user-1234",
    })
    if err != nil {
        panic(err)
    }

    for _, item := range resp.Data {
        var vec []float32
        if err := json.Unmarshal(item.Embedding, &vec); err != nil {
            panic(err)
        }
        head := vec
        if len(head) > 8 {
            head = head[:8]
        }
        fmt.Println(item.Index, head)
    }
}

Using dots, the official DigitalOcean API client for JavaScript:

import { InferenceClient } from "@digitalocean/dots";

const client = new InferenceClient({
    apiKey: process.env.DIGITALOCEAN_TOKEN,
});

const resp = await client.embeddings.create({
    model: "qwen3-embedding-0.6b",
    input: ["hello world", "goodbye world"],
    encoding_format: "float",
    user: "user-1234",
});

for (const item of resp.data) {
    console.log(item.index, item.embedding.slice(0, 8));
}

Send a POST request to https://inference.do-ai.run/v1/embeddings.

Using cURL:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  -d '{"model":"qwen3-embedding-0.6b","input":["hello world","goodbye world"],"encoding_format":"float","user":"user-1234"}' \
  "https://inference.do-ai.run/v1/embeddings"

You can also use the Go SDK (Godo):

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/digitalocean/godo"
)

func main() {
	client := godo.NewFromToken(os.Getenv("MODEL_ACCESS_KEY"))
	ctx := context.Background()

	resp, _, err := client.Embeddings.New(ctx, &godo.EmbeddingNewParams{
		Model: "qwen3-embedding-0.6b",
		Input: []string{"hello world", "goodbye world"},
	})
	if err != nil {
		panic(err)
	}

	for _, item := range resp.Data {
		var vec []float32
		if err := json.Unmarshal(item.Embedding, &vec); err != nil {
			panic(err)
		}
		fmt.Println(item.Index, len(vec))
	}
}

We can't find any results for your search.

Try using different keywords or simplifying your search terms.