Skip to content

examples: add Tuning Engines OpenAI-compatible endpoint#1333

Open
cerebrixos wants to merge 1 commit into
VoltAgent:mainfrom
cerebrixos:tuning-engines-example
Open

examples: add Tuning Engines OpenAI-compatible endpoint#1333
cerebrixos wants to merge 1 commit into
VoltAgent:mainfrom
cerebrixos:tuning-engines-example

Conversation

@cerebrixos
Copy link
Copy Markdown

@cerebrixos cerebrixos commented May 30, 2026

Summary

  • add a runnable with-tuning-engines example alongside the existing provider examples
  • configure @ai-sdk/openai with a custom baseURL and TUNING_ENGINES_API_KEY
  • update the examples index to include the new example

Why

We are an AI infrastructure team using VoltAgent with Tuning Engines. VoltAgent remains the agent runtime for tools, memory, and server behavior; Tuning Engines provides a governed OpenAI-compatible endpoint for model access, policy checks, audit logs, traces, and usage/cost reporting. Since the examples already include provider/gateway setups such as OpenRouter, this gives teams using Tuning Engines a starter that matches the existing examples structure. It would mean a lot to us if this is useful, and I am happy to adjust the example to fit your conventions.

Validation

  • git diff --check
  • attempted dependency install for the example; the repo-wide pnpm workspace install failed locally because the machine ran out of disk while fetching workspace dependencies, so I did not complete a TypeScript build in this environment

Summary by cubic

Adds a runnable with-tuning-engines example that routes VoltAgent model calls through a governed OpenAI-compatible endpoint. This enables policy checks, traces, and usage/cost reporting without changing agent code.

  • New Features
    • New examples/with-tuning-engines using @ai-sdk/openai with a custom baseURL and TUNING_ENGINES_API_KEY.
    • Optional TUNING_ENGINES_MODEL env var (defaults to gpt-4o); .env.example included.
    • Hono server via @voltagent/server-hono and local memory with @voltagent/libsql.
    • Added Tuning Engines to the examples index.

Written for commit 67305f3. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added a new "Tuning Engines" example demonstrating VoltAgent integration with a governed OpenAI-compatible endpoint for routing model calls, policy enforcement, traces, and usage/cost reporting.
  • Documentation

    • Comprehensive example documentation including prerequisites, installation steps, development commands, environment configuration, and project structure guidance for the new integration.

Review Change Stack

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 30, 2026

⚠️ No Changeset found

Latest commit: 67305f3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 30, 2026

📝 Walkthrough

Walkthrough

This PR adds a new example project demonstrating VoltAgent integration with Tuning Engines as a governed OpenAI-compatible endpoint. The example includes documentation, project configuration, environment setup, and a working implementation that initializes a VoltAgent with OpenAI client routing, LibSQL memory persistence, and Hono server.

Changes

Tuning Engines Example

Layer / File(s) Summary
Example documentation and announcement
examples/README.md, examples/with-tuning-engines/README.md
Example is registered in the main index and documented with prerequisites, installation, environment variables, development commands, feature overview, and project structure.
Project configuration and dependencies
examples/with-tuning-engines/package.json, examples/with-tuning-engines/tsconfig.json
Package defines dependencies (@ai-sdk/openai, @voltagent/* packages, hono), build/dev scripts, ES module configuration, and TypeScript compiler with ES2022 target and strict mode.
Environment setup and example implementation
examples/with-tuning-engines/.env.example, examples/with-tuning-engines/src/index.ts
Environment template captures Tuning Engines API credentials and model alias; example entrypoint validates configuration, constructs tuning-engines OpenAI client, instantiates VoltAgent with memory adapter, starts Hono server, and runs sample generateText() request with logging.

Sequence Diagram

sequenceDiagram
  participant Env as Environment
  participant App as VoltAgent Example
  participant OpenAI as OpenAI Client<br/>(Tuning Engines)
  participant Mem as LibSQL Memory
  participant Server as Hono Server
  Env->>App: TUNING_ENGINES_API_KEY<br/>(validation)
  App->>OpenAI: new OpenAI client<br/>(baseURL=tuning-engines)
  App->>Mem: new Memory<br/>(LibSQL adapter)
  App->>Server: new honoServer()<br/>with VoltAgent
  Server->>App: server listening:3141
  App->>OpenAI: generateText()<br/>sample request
  OpenAI->>App: text + usage
  App->>App: log results
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • omeraplak

Poem

🐰 A new example hops into the fold,
Tuning Engines routing, stories yet untold,
With Hono and memory, VoltAgent takes flight,
Through governance gates to models so bright! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description includes summary, rationale, and validation details, but lacks required PR checklist items (commit message compliance, linked issues, tests, docs/changesets confirmation). Complete the PR checklist by confirming commit message guidelines compliance, linking related issues, noting test/doc/changeset status, or stating N/A if not applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a Tuning Engines example with an OpenAI-compatible endpoint to the examples directory.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
examples/with-tuning-engines/package.json (1)

1-39: ⚡ Quick win

Add a Node engine constraint to match the documented prerequisite.

Line 11 in the README requires Node.js v20+, but this package doesn’t enforce it. Adding engines prevents accidental installs/runs on unsupported Node versions.

Suggested patch
 {
   "name": "voltagent-example-with-tuning-engines",
   "author": "",
+  "engines": {
+    "node": ">=20"
+  },
   "dependencies": {
     "`@ai-sdk/openai`": "^3.0.0",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/with-tuning-engines/package.json` around lines 1 - 39, Add an
"engines" field to package.json to enforce the documented Node.js prerequisite
(v20+); update the root JSON object (the same level as "type", "scripts",
"dependencies") to include "engines": { "node": ">=20.0.0" } so installs on
older Node versions fail with a clear constraint message and prevent accidental
runs on unsupported Node versions.
examples/with-tuning-engines/src/index.ts (1)

39-48: ⚡ Quick win

Handle request failures in the demo IIFE.

Line 39 starts an async IIFE with no error handling; transient API/network errors can fail noisily and obscure what happened. Wrap it in try/catch and log the error.

Suggested patch
 (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,
-  });
+  try {
+    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,
+    });
+  } catch (error) {
+    logger.error("Tuning Engines example request failed", { error });
+    process.exitCode = 1;
+  }
 })();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/with-tuning-engines/src/index.ts` around lines 39 - 48, The async
IIFE that calls agent.generateText and then logger.info should be wrapped in a
try/catch to handle transient API/network failures: surround the await
agent.generateText(...) and subsequent logger.info(...) with try { ... } catch
(err) { logger.error("Tuning Engines example request failed", { error: err }) }
so failures are logged instead of crashing; reference the existing async IIFE,
agent.generateText, and logger.info to find where to add the try/catch.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@examples/with-tuning-engines/package.json`:
- Around line 1-39: Add an "engines" field to package.json to enforce the
documented Node.js prerequisite (v20+); update the root JSON object (the same
level as "type", "scripts", "dependencies") to include "engines": { "node":
">=20.0.0" } so installs on older Node versions fail with a clear constraint
message and prevent accidental runs on unsupported Node versions.

In `@examples/with-tuning-engines/src/index.ts`:
- Around line 39-48: The async IIFE that calls agent.generateText and then
logger.info should be wrapped in a try/catch to handle transient API/network
failures: surround the await agent.generateText(...) and subsequent
logger.info(...) with try { ... } catch (err) { logger.error("Tuning Engines
example request failed", { error: err }) } so failures are logged instead of
crashing; reference the existing async IIFE, agent.generateText, and logger.info
to find where to add the try/catch.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8fe86834-8fd0-49a3-81a5-25dd41677456

📥 Commits

Reviewing files that changed from the base of the PR and between 41cad53 and 67305f3.

📒 Files selected for processing (6)
  • examples/README.md
  • examples/with-tuning-engines/.env.example
  • examples/with-tuning-engines/README.md
  • examples/with-tuning-engines/package.json
  • examples/with-tuning-engines/src/index.ts
  • examples/with-tuning-engines/tsconfig.json

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant