Skip to content

Doubleword

batchling is compatible with Doubleword through any supported framework

The following endpoints are made batch-compatible by Doubleword:

  • /v1/chat/completions
  • /v1/responses
  • /v1/embeddings
  • /v1/moderations
  • /v1/completions

Check model support and batch pricing

Before sending batches, review the provider's official pricing page for supported models and batch pricing details.

The Batch API docs for Doubleword can be found on the following URL:

https://docs.doubleword.ai/batches/getting-started-with-batched-api

Example Usage

API key required

Set DOUBLEWORD_API_KEY in .env or ensure it is already loaded in your environment variables before running batches.

Here's an example showing how to use batchling with Doubleword:

doubleword_example.py
import asyncio
import os

from dotenv import load_dotenv
from openai import AsyncOpenAI

from batchling import batchify

load_dotenv()


async def build_tasks() -> list:
    """Build OpenAI requests."""
    client = AsyncOpenAI(
        api_key=os.getenv(key="DOUBLEWORD_API_KEY"), base_url="https://api.doubleword.ai/v1"
    )
    questions = [
        "Who is the best French painter? Answer in one short sentence.",
        "What is the capital of France?",
    ]
    return [
        client.responses.create(
            input=question,
            model="openai/gpt-oss-20b",
        )
        for question in questions
    ]


async def main() -> None:
    """Run the OpenAI example."""
    tasks = await build_tasks()
    responses = await asyncio.gather(*tasks)
    for response in responses:
        content = response.output[-1].content  # skip reasoning output, get straight to the answer
        print(f"{response.model} answer:\n{content[0].text}\n")


async def run_with_batchify() -> None:
    """Run `main` inside `batchify` for direct script execution."""
    async with batchify():
        await main()


if __name__ == "__main__":
    asyncio.run(run_with_batchify())

Output:

openai/gpt-oss-20b answer:
Claude Monet is often regarded as the best French painter.

openai/gpt-oss-20b answer:
The capital of France is Paris.