Migrating to v2 API
Guide to migrating code to use version 2 api
With our version 2 API, SDKs and Docs we are unifying the experience of building with Opper across languages. Migrating to version 2 is essentially just syntax changes. API-keys, index information and Schemas will continue to work as earlier, but need the syntax to use them have changed.
See docs for more information.
Key changes
1. Terminology: “Calls” → “Task completion”
All docs, navigation, and code now talk about tasks and task completions instead of calls. The call endpoint is still the same, but we are emphasising that the parameters to the call is a task specification.
2. Parameter rename: …_type
→ …_schema
Python switches
input_type / output_type
→ input_schema / output_schema
(TypeScript was already using “…Schema”.)
3. Single-object response
v1 returned a tuple:
v2 returns one object:
4. Span-based tracing
Replace the @trace
decorator and opper.traces.*
context manager with explicit span helpers:
5. Dedicated streaming endpoint
Streaming moves from
to
6. Model fall-backs folded into model=
7. Flat configuration={}
CallConfiguration(...)
disappears—use dot-notation keys in a plain dict:
For model/provider specific configuration pass model as a dict:
8. Arbitrary tagging
Attach tags to completions or spans for richer filtering, billing, and analytics.
9. Indexes renamed to Knowledge
SDK namespaces change:
10. Synchronous client is now the default
To use async mehtods, append _async
after the operation - for example call_async()
11. Server-side functions API added
opper.functions.create / get / call
lets you store and version task definitions centrally.
Migration Guide
Migrate step-by-step; each change is independent.
-
Switch the client import
-
Rename parameters
-
Handle the single response object
-
Adopt span-based tracing
Add metrics if you collect feedback:
-
Move streaming code
-
Collapse primary + fallback models
-
Flatten any
CallConfiguration
usage -
Add tags (optional)
-
Update Indexes → Knowledge calls
-
Retest and deploy
Tip: Start with the parameter rename and single-response handling; tracing and streaming can be migrated later without breaking existing code.