Skip to content
Open
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
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Create a multi-agent research workflow where different AI agents collaborate to
- [Amazon Bedrock](./with-amazon-bedrock) — Run AWS Bedrock models by configuring credentials and model IDs in VoltAgent.
- [Anthropic](./with-anthropic) — Use Claude models as your agent’s LLM via the AI SDK.
- [OpenRouter](./with-openrouter) — Use OpenRouter through VoltAgent's built-in `openrouter/<model>` routing.
- [Tuning Engines](./with-tuning-engines) — Route VoltAgent model calls through a governed OpenAI-compatible endpoint for policy, traces, and usage/cost reporting.
- [Chroma](./with-chroma) — RAG with Chroma vectors showing automatic vs tool‑driven retrieval patterns.
- [Client‑side Tools](./with-client-side-tools) — Next.js UI triggers typed client‑side tools safely, VoltAgent on the server.
- [Cloudflare Workers](./with-cloudflare-workers) — Deploy your agent on Workers using the Hono server adapter.
Expand Down
2 changes: 2 additions & 0 deletions examples/with-tuning-engines/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TUNING_ENGINES_API_KEY=sk-te-your-inference-key
TUNING_ENGINES_MODEL=gpt-4o
75 changes: 75 additions & 0 deletions examples/with-tuning-engines/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# with-tuning-engines

A [VoltAgent](https://github.com/VoltAgent/voltagent) application using Tuning Engines as a governed OpenAI-compatible endpoint.

Tuning Engines can sit between VoltAgent and the underlying model providers so that VoltAgent owns the agent runtime, tools, and memory, while Tuning Engines centralizes model access, policy checks, audit logs, traces, and usage/cost reporting.

## Getting Started

### Prerequisites

- Node.js (v20 or newer)
- npm, yarn, or pnpm
- A Tuning Engines inference key with access to the model alias you want to use

### Installation

1. Clone this repository
2. Install dependencies
3. Copy `.env.example` to `.env`
4. Set `TUNING_ENGINES_API_KEY`
5. Optionally set `TUNING_ENGINES_MODEL`

```bash
npm install
# or
yarn
# or
pnpm install
```

### Development

Run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
```

The example starts a VoltAgent server on port `3141`.

The dev script uses `tsx watch --env-file=.env ./src`, matching the example's `package.json` setup.

## What This Example Shows

- `Agent` configured with `@ai-sdk/openai` and a custom `baseURL`
- Tuning Engines inference key usage via `TUNING_ENGINES_API_KEY`
- Optional model alias selection via `TUNING_ENGINES_MODEL`
- Local memory storage with LibSQL
- Hono server integration through `@voltagent/server-hono`

## Notes

Use `pnpm build && pnpm start` for the compiled output, or `pnpm dev` during development.

## Project Structure

```text
.
├── src/
│ └── index.ts
├── .env.example
├── package.json
├── tsconfig.json
└── README.md
```

## Try Example

```bash
npm create voltagent-app@latest -- --example with-tuning-engines
```
39 changes: 39 additions & 0 deletions examples/with-tuning-engines/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "voltagent-example-with-tuning-engines",
"author": "",
"dependencies": {
"@ai-sdk/openai": "^3.0.0",
"@voltagent/cli": "^0.1.21",
"@voltagent/core": "^2.7.5",
"@voltagent/libsql": "^2.1.2",
"@voltagent/logger": "^2.0.2",
"@voltagent/server-hono": "^2.0.13",
"ai": "^6.0.0"
},
"devDependencies": {
"@types/node": "^24.2.1",
"tsx": "^4.21.0",
"typescript": "^5.8.2"
},
"keywords": [
"agent",
"ai",
"openai-compatible",
"tuning-engines",
"voltagent"
],
"license": "MIT",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/VoltAgent/voltagent.git",
"directory": "examples/with-tuning-engines"
},
"scripts": {
"build": "tsc",
"dev": "tsx watch --env-file=.env ./src",
"start": "node dist/index.js",
"volt": "volt"
},
"type": "module"
}
48 changes: 48 additions & 0 deletions examples/with-tuning-engines/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { createOpenAI } from "@ai-sdk/openai";
import { Agent, Memory, VoltAgent } from "@voltagent/core";
import { LibSQLMemoryAdapter } from "@voltagent/libsql";
import { createPinoLogger } from "@voltagent/logger";
import { honoServer } from "@voltagent/server-hono";

if (!process.env.TUNING_ENGINES_API_KEY) {
throw new Error("TUNING_ENGINES_API_KEY is required");
}

const tuningEngines = createOpenAI({
apiKey: process.env.TUNING_ENGINES_API_KEY,
baseURL: "https://api.tuningengines.com/v1",
});

const logger = createPinoLogger({
name: "with-tuning-engines",
level: "info",
});

const agent = new Agent({
name: "Tuning Engines Assistant",
instructions:
"You are a helpful assistant running through a governed OpenAI-compatible endpoint.",
model: tuningEngines(process.env.TUNING_ENGINES_MODEL ?? "gpt-4o"),
memory: new Memory({
storage: new LibSQLMemoryAdapter(),
}),
});

new VoltAgent({
agents: {
agent,
},
logger,
server: honoServer(),
});

(async () => {
const result = await agent.generateText(
"Explain how policy, traces, and usage reporting help production AI agents.",
);

logger.info("Tuning Engines example request completed", {
text: result.text,
usage: result.usage,
});
})();
13 changes: 13 additions & 0 deletions examples/with-tuning-engines/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "dist"
},
"include": ["src/**/*.ts"]
}