Skip to main content

Gridline

Application code names a role. Configuration decides which model serves it, what it can reach for, and what happens when a provider goes down.

There are two ways in, and the first one asks less of you.


1. Keep the client you already have

Gridline speaks the providers' own APIs and, on request, answers in their own bytes. So point your existing client at it, name a Gridline agent in the model string, and stop.

curl https://gridline.internal/v1/messages \
  -H "authorization: Bearer $GRIDLINE_KEY" \
  -H "content-type: application/json" \
  -d '{
        "model": "gridline/invoice-reconciler",
        "format": "raw",
        "max_tokens": 1024,
        "messages": [{"role": "user", "content": "What did we agree about the VAT deadline?"}]
      }'

Three things are happening there:

  • model: "gridline/<agent>" names the agent. The agent's configuration decides the real model and its fallbacks, so nothing in your code names a vendor.
  • format: "raw" returns the provider's own response shape, and on an ordinary turn its exact bytes (a turn the proxy ran a tool loop for is assembled from several calls, so it is provider-shaped rather than byte-identical -- see docs/30), so your SDK's parser keeps working. Leave it out and you get the canonical shape below instead — which is a third shape, and a strict client will reject it.
  • authorization: Bearer is a Gridline route key, not a provider key. Provider credentials stay in your own secret manager and are resolved in the data plane.

The same request from the official Anthropic SDK, LangChain, or Vercel's @ai-sdk/anthropic is a base URL and a model string. Worked examples for each, plus what this route cannot do — approvals, mainly — are in docs/30-passthrough.md. Read the last section of that page before shipping it.


2. Or use this library

For approvals, one response shape across every provider, and sessions handled for you.

uv pip install -e ./sdk    # nothing is published yet; this is the repository copy
import gridline

grid = gridline.connect("https://gridline.internal", key="gl_...")
chat = grid.session(
    agent="invoice-reconciler",
    assign={"memory": {"store": "acme-ledgers", "subject": "user-123"}},
)

answer = await chat.send("What did we agree about the VAT deadline?")
print(answer.text)

It is asynchronous, and that is the default rather than the advanced option. A turn is almost entirely spent waiting on a model, and a turn that runs tools waits several times, so blocking a thread for it is the wrong shape in anything serving requests.

If you want the blocking one, that is one argument and nothing else changes:

grid = gridline.connect("https://gridline.internal", key="gl_...", sync=True)
answer = chat.send("What did we agree about the VAT deadline?")   # no await

Every other name is identical between them — send, stream, resume, the reply, and .text/.reply/.tool_calls/.session on a stream — so moving a handler from one to the other is adding or deleting async and await. That choice is usually made after the code is written, and it should not be a rewrite when it is.

A session is a conversation, not a connection. It holds nothing the proxy does not also hold, so grid.session(agent=..., resume=answer.session) in another process carries on where this one stopped.

One reply shape, whoever served it. answer.text, answer.tool_calls, answer.usage, answer.stop_reason — and answer.raw is still exactly what the provider sent, for the days you need a vendor detail this shape does not model.

Degradation is readable rather than silent. answer.degraded is true when the turn got less than it was configured for; route_degraded, session_degraded and tools_degraded say which, because a fallback model and a lost memory are not the same problem. answer.context_compacted sits beside them rather than inside: a shortened conversation is the harness working as configured, not a shortfall, but the model still answered from less than you sent and nothing else in the reply says so.

Retries are narrow on purpose. A turn is not idempotent, so the client only repeats what it knows did not run — a connection that was never established, a 429, a 503. A read timeout is never retried, because the request arrived and something is working on it. Pass retry=gridline.Retry(attempts=5) to widen it, or gridline.NO_RETRY to turn it off.

Approvals. A tool configured to ask pauses the turn instead of running:

answer = chat.send("post the January invoices")
if answer.awaiting_approval:
    for request in answer.approvals:
        print(request.name, request.arguments)      # a decision, not a button
    answer = chat.resume({r.id: True for r in answer.approvals})

The id is the call's, not the tool's: approving this post_invoice with these arguments is something a person can be accountable for.

Streaming.

with chat.stream("summarise the January ledger") as answer:
    for piece in answer:
        print(piece, end="", flush=True)
    print(answer.reply.usage.output_tokens)

Same arguments as send. Switching between them is adding or deleting a for loop.


Which one

Take route 1 if you have an application already and want routing, failover and cost attribution underneath it today. Take route 2 if a tool needs approving before it runs, if you want one parsing path across providers, or if a degraded turn has to reach a person. Nothing you configure differs between them, and running both against the same agent is normal.

Metadata

Release files for gridline 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gridline 0.2.1
File Size Uploaded Provenance Actions
gridline-0.2.1.tar.gz 58.5 kB With provenance Details for gridline-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gridline 0.2.1
File Interpreter ABI Platform Actions
gridline-0.2.1-py3-none-any.whl Python 3 none any Details for gridline-0.2.1-py3-none-any.whl

Total release size: 104.1 kB

Release files / gridline-0.2.1.tar.gz

Download URL gridline-0.2.1.tar.gz
Size 58.5 kB
Tags Source
SHA-256 checksum
How to use checksums
760e379f5d0d35022a1efdb14ecc305e3af30a24c8fafd2312eae1e26da35b37
BLAKE2b-256 checksum
How to use checksums
07428bbb40f5f3af2b67655875b533628ca80ad9139fd993a8e420a2ff73b4ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.

Transparency log

Release files / gridline-0.2.1-py3-none-any.whl

Download URL gridline-0.2.1-py3-none-any.whl
Size 45.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12e6c5ab5278764df9c371992e5f699098808425bfbaf75e86d6032aac295241
BLAKE2b-256 checksum
How to use checksums
bbbd21c1ce8e0ad36811e6b48908f2f61c1349fe6f7960998a04664a5eced8e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.

Transparency log

Security for gridline 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gridline-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page