DoublewordDoubleword

Agno

Agno (formerly Phidata) provides an OpenAILike model class designed for custom OpenAI-compatible endpoints.

Install

pip install agno openai

Configure

from agno.agent import Agent
from agno.models.openai import OpenAILike

agent = Agent(
    model=OpenAILike(
        id="{{selectedModel.id}}",
        base_url="https://api.doubleword.ai/v1",
        api_key="{{apiKey}}",
    )
)

agent.print_response("Say hello.")

Batch pricing with Autobatcher

For background tasks where latency is not critical, use Autobatcher to transparently route requests through the Batch API at reduced cost:

pip install agno openai autobatcher
from autobatcher import BatchOpenAI
from agno.agent import Agent
from agno.models.openai import OpenAILike
import asyncio

client = BatchOpenAI(
    api_key="{{apiKey}}",
    base_url="https://api.doubleword.ai/v1",
)

agent = Agent(
    model=OpenAILike(
        id="{{selectedModel.id}}",
        async_client=client,
    )
)

async def main():
    response = await agent.arun("Say hello.")
    print(response.content)
    await client.close()

asyncio.run(main())

BatchOpenAI is a drop-in AsyncOpenAI subclass that collects requests and submits them as batch jobs automatically, cutting inference costs by up to 90%.