@rouvanpm/rouva 0.2.10 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -119,13 +119,13 @@ Models not recognised by the gateway return a `400` immediately:
|
|
|
119
119
|
|
|
120
120
|
Using the OpenAI SDK (or LangChain, the Vercel AI SDK, …) instead of this one? The gateway is also served at `POST /v1/chat/completions` — point `baseURL` at `https://app.rouva.io/v1` with your `rva_` key and it behaves exactly like OpenAI: `model` is required, responses are buffered JSON unless `stream: true`, and only OpenAI-format providers are available (use this SDK or the native endpoint for Anthropic models).
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
Non-tools requests on `/v1` always honor the named model exactly. **Tools requests on `/v1` benefit from within-provider intelligent routing** when Intelligent Routing is enabled in your dashboard — Rouva picks the cheapest capable model within the same provider, using the named `model` as a cost ceiling. The provider never changes (tool schemas are provider-specific), and `response.model` reflects the model that actually served the request. Turn Intelligent Routing off in dashboard Settings → Gateway to always pin the exact model.
|
|
123
123
|
|
|
124
124
|
## Tool use
|
|
125
125
|
|
|
126
126
|
Tools are forwarded to your target provider verbatim — define them in the **provider's own format** (OpenAI `{ type: "function", function: {...} }` or Anthropic `{ name, description, input_schema }`) and pin the matching `model`. Tool schemas are provider-specific, so `model` is required and the gateway returns a 400 without it.
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
When using the `/v1` endpoint (OpenAI SDK, LangChain, Vercel AI SDK, …) with Intelligent Routing enabled, tools requests are routed to the cheapest capable model within the same provider — see [OpenAI-compatible endpoint](#openai-compatible-endpoint) for details. On the native SDK endpoint (`/api/gateway/messages`), the named model is always honored exactly.
|
|
129
129
|
|
|
130
130
|
```typescript
|
|
131
131
|
const res = await rouva.chat.completions.create({
|
|
@@ -167,7 +167,7 @@ Responses are normalized to the OpenAI shape regardless of provider: Anthropic `
|
|
|
167
167
|
|
|
168
168
|
**Don't branch on `finish_reason` to detect tool calls** — check for the presence of `message.tool_calls` instead. `finish_reason` follows each provider's own semantics, and OpenAI notably returns `"stop"` (not `"tool_calls"`) when `tool_choice` forces a specific function. The SDK passes OpenAI's values through unchanged so behavior matches calling OpenAI directly.
|
|
169
169
|
|
|
170
|
-
Tools requests record usage and cost
|
|
170
|
+
Tools requests record usage and cost. Savings are recorded when within-provider routing substitutes a cheaper model on `/v1`. Tools responses are not quality-scored or served from the semantic cache.
|
|
171
171
|
|
|
172
172
|
## Cost optimisations
|
|
173
173
|
|
|
@@ -190,6 +190,33 @@ const rouva = new Rouva({
|
|
|
190
190
|
})
|
|
191
191
|
```
|
|
192
192
|
|
|
193
|
+
## Agent session tracking
|
|
194
|
+
|
|
195
|
+
Group all turns of an agent run under a single session ID so the Rouva dashboard can show per-session cost, token usage, and quality.
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
const rouva = new Rouva({ apiKey: 'rva_...' })
|
|
199
|
+
|
|
200
|
+
// Start a session — auto-generates an ID and attaches it to every request
|
|
201
|
+
const sessionId = rouva.startSession()
|
|
202
|
+
|
|
203
|
+
// All turns carry the same session ID automatically
|
|
204
|
+
await rouva.chat.completions.create({ messages: [...], tools: [...] })
|
|
205
|
+
await rouva.chat.completions.create({ messages: [...], tools: [...] })
|
|
206
|
+
await rouva.chat.completions.create({ messages: [...], tools: [...] })
|
|
207
|
+
|
|
208
|
+
// End the session when the agent run is complete
|
|
209
|
+
rouva.endSession()
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
You can also read the active session ID at any time:
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
console.log(rouva.sessionId) // 'rva-sess-abc123' or undefined
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Sessions are optional — requests without an active session are tracked individually as before.
|
|
219
|
+
|
|
193
220
|
## Response metadata
|
|
194
221
|
|
|
195
222
|
Parsed non-stream responses may include a `_rouva` field with gateway header metadata when available:
|
package/package.json
CHANGED