PureRouter is a completely independent product from PureCPP. You can use
PureRouter without needing PureCPP and vice versa.
In addition to automatic routing through profiles, PureRouter allows you to directly access specific models through their deployment IDs. This is useful when you need a particular model for a specific use case.
import asyncioimport jsonimport sysfrom purerouter import AsyncPureRouterfrom purerouter.types import InvokeRequestasync def main(): client = AsyncPureRouter( router_key="sk_...", base_url="https://api.purerouter-api.com", timeout=300.0 ) deployment_id = "" req = InvokeRequest( prompt="Hi.", max_tokens=250, temperature=0.8, stream=True ) final = [] async for ev in client.deployments.astream(deployment_id, req): line = (ev.data or "").strip() if not line or line == "[DONE]": continue if line.startswith("data:"): line = line[len("data:"):].strip() try: obj = json.loads(line) except json.JSONDecodeError: sys.stdout.write(line) sys.stdout.flush() final.append(line) continue choices = obj.get("choices") or [] if choices and isinstance(choices[0], dict) and "text" in choices[0]: tok = choices[0]["text"] or "" sys.stdout.write(tok) sys.stdout.flush() final.append(tok)asyncio.run(main())
When you need absolute consistency in responses, always using the same model through the deployment ID ensures you’ll get predictable results, without variations that can occur with automatic routing.
Specialized Models
If you’ve deployed a fine-tuned model for a specific task, you can access it
directly by ID to leverage its specialized training.
Comparative Testing
To compare the performance of different models on the same task, you can
invoke each one directly and evaluate the results.
Regulatory Requirements
In scenarios where there are specific regulatory requirements about which models can be used, direct access ensures compliance.
Após criar um deployment, você receberá um ID único que identifica seu modelo específico. É com esse ID que você vai se comunicar diretamente com o deployment através da API.O Deployment ID é essencial para: