DigitalOcean.GenAI reference
Source:
packages/digitalocean/src/GenAI/Agent.ts
A DigitalOcean GenAI Platform agent: a hosted model with your
instructions and optional knowledge bases behind a private chat endpoint.
Call it with an AgentApiKey and the InvokeAgent binding. The model,
instructions, knowledge bases and tuning update in place; projectId and
region replace the agent.
Agent: Creating an Agent
Section titled “Agent: Creating an Agent”const project = yield* DigitalOcean.Project("support", {});const docs = yield* DigitalOcean.GenAI.KnowledgeBase("docs", { projectId: project.projectId, embeddingModel: "GTE Large EN v1.5", sources: [{ webCrawler: { baseUrl: "https://docs.example.com" } }],});const agent = yield* DigitalOcean.GenAI.Agent("support", { projectId: project.projectId, model: "Ministral 3 14B", instruction: "Answer questions about Example Corp. using the docs.", knowledgeBaseIds: [docs.knowledgeBaseId],});AgentApiKey
Section titled “AgentApiKey”Source:
packages/digitalocean/src/GenAI/AgentApiKey.ts
A key that authorizes calls to one GenAI agent’s endpoint. DigitalOcean
returns the secret only at create, so Alchemy keeps it in state as a
Redacted value. Pass it to InvokeAgent, or to any OpenAI-compatible
client as the API key.
AgentApiKey: Calling an Agent
Section titled “AgentApiKey: Calling an Agent”const key = yield* DigitalOcean.GenAI.AgentApiKey("support-key", { agentId: agent.agentId,});CustomModel
Section titled “CustomModel”Source:
packages/digitalocean/src/GenAI/CustomModel.ts
An open-weight model imported into your team, from a Hugging Face repository or a Spaces bucket, to serve with Dedicated Inference. Deploy waits until the import finishes.
CustomModel: Importing a Model
Section titled “CustomModel: Importing a Model”From Hugging Face
const model = yield* DigitalOcean.GenAI.CustomModel("Qwen", { source: { huggingFace: "Qwen/Qwen2.5-0.5B-Instruct" },});A gated model, with your Hugging Face token
const token = yield* Config.Redacted("HF_TOKEN");const model = yield* DigitalOcean.GenAI.CustomModel("Llama", { source: { huggingFace: "meta-llama/Llama-3.2-1B-Instruct", token },});From a Spaces bucket
const model = yield* DigitalOcean.GenAI.CustomModel("FineTuned", { source: { bucket: "models", region: "nyc3", prefix: "my-model/" },});InvokeAgent
Section titled “InvokeAgent”Source:
packages/digitalocean/src/GenAI/InvokeAgent.ts
Calls a GenAI agent’s chat endpoint from a runtime. Binding it mints an
AgentApiKey for the host, because DigitalOcean signs no workload
identity a runtime could present instead; the key travels to the host as
a secret.
InvokeAgent: Examples
Section titled “InvokeAgent: Examples”export default class Api extends DigitalOcean.App<Api>()( "Api", { main: import.meta.url }, Effect.gen(function* () { const support = yield* DigitalOcean.GenAI.InvokeAgent(SupportAgent); return { fetch: Effect.gen(function* () { const answer = yield* support.ask("How do I reset my password?"); return HttpServerResponse.text(answer); }).pipe(Effect.orDie), }; }).pipe(Effect.provide(DigitalOcean.GenAI.InvokeAgentHttp)),) {}InvokeAgentHttp
Section titled “InvokeAgentHttp”Source:
packages/digitalocean/src/GenAI/InvokeAgentHttp.tsKind: Layer · Provides:DigitalOcean.GenAI.InvokeAgent
InvokeAgent over the agent’s OpenAI-compatible chat endpoint, with an
AgentApiKey minted for the host.
KnowledgeBase
Section titled “KnowledgeBase”Source:
packages/digitalocean/src/GenAI/KnowledgeBase.ts
A DigitalOcean GenAI knowledge base: content from Spaces buckets or
crawled websites, embedded and indexed in an OpenSearch database, that
agents retrieve from. Attach it to an Agent with knowledgeBaseIds.
Without databaseId, DigitalOcean provisions an OpenSearch cluster for
the knowledge base, billed while it exists; Alchemy destroys that cluster
when it destroys the knowledge base.
KnowledgeBase: Creating a Knowledge Base
Section titled “KnowledgeBase: Creating a Knowledge Base”Index a documentation site
const docs = yield* DigitalOcean.GenAI.KnowledgeBase("docs", { projectId: project.projectId, embeddingModel: "GTE Large EN v1.5", sources: [ { webCrawler: { baseUrl: "https://docs.example.com", crawlingOption: "PATH" } }, ],});Index the files in a Spaces bucket
const files = yield* DigitalOcean.Spaces.Bucket("files", { region: "nyc3" });const kb = yield* DigitalOcean.GenAI.KnowledgeBase("files", { projectId: project.projectId, embeddingModel: "GTE Large EN v1.5", sources: [{ spaces: { bucketName: files.bucketName, region: "nyc3" } }],});ModelRouter
Section titled “ModelRouter”Source:
packages/digitalocean/src/GenAI/ModelRouter.ts
A model router: picks a model per request by task, with fallbacks. Every field updates in place.
ModelRouter: Routing by Task
Section titled “ModelRouter: Routing by Task”yield* DigitalOcean.GenAI.ModelRouter("chat", { description: "Chat with a cheap fallback", fallbackModels: ["mistral-3-14B"],});ProviderKey
Section titled “ProviderKey”Source:
packages/digitalocean/src/GenAI/ProviderKey.ts
Your own OpenAI or Anthropic API key, registered with the GenAI Platform so agents can run on that provider’s models, billed to your provider account. DigitalOcean validates the key when it is added.
ProviderKey: Bringing Your Own Key
Section titled “ProviderKey: Bringing Your Own Key”const apiKey = yield* Config.Redacted("ANTHROPIC_API_KEY");yield* DigitalOcean.GenAI.ProviderKey("anthropic", { provider: "anthropic", apiKey });Workspace
Section titled “Workspace”Source:
packages/digitalocean/src/GenAI/Workspace.ts
A GenAI workspace: a group of agents that share access and evaluations.
Agents listed in agentIds are moved into it.
Workspace: Grouping Agents
Section titled “Workspace: Grouping Agents”yield* DigitalOcean.GenAI.Workspace("support", { description: "Customer support agents", agentIds: [triage.agentId, billing.agentId],});