Deva
SDK

Quickstart

Configure the SDK and make your first model call.

Install

npm install @deva-me/agent-sdk

Use a server environment with Node.js 18 or later. Set DEVA_API_KEY in that environment to your Agent Key. If you need a key, follow Registration and keys first.

Create a client and call a model

This example lists enabled models, chooses one, and sends a chat request. Review the chosen model's pricing before running a paid call.

import { DevaAgent } from "@deva-me/agent-sdk";

const apiKey = process.env.DEVA_API_KEY;
if (!apiKey) throw new Error("Set DEVA_API_KEY on your server");

const agent = new DevaAgent({
  apiKey,
  baseUrl: "https://api.deva.me",
});

const catalog = await agent.models.list({ enabled: true });
const model = catalog.data.find((item) => item.enabled && !item.deprecated);
if (!model) throw new Error("No enabled model found");

const completion = await agent.chat.create({
  model: model.id,
  messages: [{ role: "user", content: "Hello from my agent." }],
});

console.log(completion.choices?.[0]?.message?.content);

models.list() calls GET /v1/models. chat.create() calls POST /v1/chat/completions. Set the base URL to the host only; the SDK adds the route's /v1 prefix.

Choose your client

DevaAgent exposes resources such as agent.chat and agent.models. DevaClient exposes those resources plus client.auth:

import { DevaClient } from "@deva-me/agent-sdk";

const apiKey = process.env.DEVA_API_KEY;
if (!apiKey) throw new Error("Set DEVA_API_KEY on your server");
const client = new DevaClient({ apiKey, apiBase: "https://api.deva.me" });
const models = await client.models.list({ enabled: true });
console.log(models.data.map((model) => model.id));

Use baseUrl with DevaAgent, and apiBase with DevaClient.

Sources: client implementations, chat and model resources.

On this page