Skip to main content
Change of provenance

The repository or configuration that created this release differ from a previous release. View details.

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.4

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

Change of provenance

The repository or configuration that created these release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Source distribution (sdist)

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

Built distribution (wheel)

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

Total release size: 118.5 kB

Release files / gridline-0.2.4.tar.gz

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL gridline-0.2.4.tar.gz
Size 67.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7526e37ba9d51f326a91b9e62b5970fb1d5bce536c25677697e30e395d7d0397
BLAKE2b-256 checksum
How to use checksums
ed61e51690d778a37a3baffaf93479e47160635009cd45054029cbb2a495498d
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 4, 2026.

Transparency log

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

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL gridline-0.2.4-py3-none-any.whl
Size 50.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e5f744ae085901123f63cd0e895502bcf142e4770bbb273ae2daa9e30d0f1d9
BLAKE2b-256 checksum
How to use checksums
7f11a5d78a79c47e2b0efe45dd3261233516b3500badc0792886f887046cf0de
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 4, 2026.

Transparency log

Security for gridline 0.2.4

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.

Change of provenance

The repository and configuration that created this release differ from a previous release.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Select from 2 files

Attestation for gridline-0.2.4.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 4, 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