[bot] Add AI21 Labs Python SDK integration for chat completions and embeddings instrumentation (54,424 weekly downloads)
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- python
- Bereich
- observability
Rechercherichtung
Beginnen Sie mit dem Vergleich der OpenAI- oder Mistral-Integrationsmuster unter py/src/braintrust/integrations/, und sehen Sie sich anschließend py/noxfile.py sowie die in der Issue genannten Dateien für die Integrationsregistrierung und Versionierung an. Implementieren Sie Unterstützung für synchrone und asynchrone Chat Completions, Streaming und Embeddings einschließlich der dokumentierten Metadaten, und fügen Sie die Tests, die Registrierung, den Versionseintrag und den Dependency-Matrix-Eintrag der Integration hinzu.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
The AI21 Python SDK (ai21) is the official Python client for AI21 Labs' inference platform, which provides the Jamba model family — hybrid SSM-Transformer models optimized for long-context tasks and high throughput. Its AI21Client and AsyncAI21Client expose client.chat.completions.create() and client.embed.create() APIs. This repository has zero instrumentation for any AI21 SDK surface — no integration directory, no wrapper, no patcher, no auto_instrument() support.
AI21's Python SDK uses its own client class (ai21.AI21Client), which is not a subclass of openai.OpenAI, so wrap_openai() cannot be used with it. The pattern is the same as Groq, Mistral, and OpenRouter — OpenAI-compatible endpoint but a distinct Python client requiring a dedicated integration. Users who follow AI21's official documentation and pip install ai21 get zero Braintrust tracing.
What needs to be instrumented
The ai21 package exposes these execution surfaces via AI21Client and AsyncAI21Client, none of which are instrumented:
Chat completions (highest priority)
| SDK Method | Description | Streaming | Return type |
|---|---|---|---|
client.chat.completions.create() |
Chat completions with tool calling, structured output, and document grounding | stream=True returns Stream[ChatCompletionChunk] |
ChatCompletion |
Response shape is OpenAI-compatible: ChatCompletion has choices, usage (prompt_tokens, completion_tokens, total_tokens), model, id — standard span metrics extraction follows the OpenAI pattern.
Streaming: stream=True returns a Stream[ChatCompletionChunk] iterator. The integration must handle the streaming span lifecycle.
Embeddings
| SDK Method | Description | Return type |
|---|---|---|
client.embed.create() |
Text embeddings generation for semantic search and RAG | EmbedResponse |
Both sync (AI21Client) and async (AsyncAI21Client) clients exist with identical method signatures.
Implementation notes
Stainless-generated SDK (v3.x): The ai21 v3.x package (current major version) is generated by Stainless (same toolchain as OpenAI, Groq, Mistral). The client structure mirrors the OpenAI SDK, so the patcher/wrapper pattern from the OpenAI or Mistral integration can serve as a close structural reference.
chat.completions.create() parameters relevant for span metadata: model, temperature, max_tokens, top_p, frequency_penalty, presence_penalty, n, stop, tools, tool_choice, response_format, documents (AI21-specific grounding feature).
Document grounding: The documents parameter is AI21-specific and allows grounding responses in provided documents. This should be captured in span input metadata when present.
Model family: Jamba 1.6 Large and Jamba 1.6 Mini are the primary models. Response model field should be captured in span metadata.
No coverage in any instrumentation layer
- No integration directory (
py/src/braintrust/integrations/ai21/) - No wrapper function (e.g.
wrap_ai21()) - No patcher in any existing integration
- No nox test session (
test_ai21) - No version entry in
py/src/braintrust/integrations/versioning.py - No mention in
py/src/braintrust/integrations/__init__.py - No entry in
[tool.braintrust.matrix]inpy/pyproject.toml
A grep for ai21 across py/src/braintrust/ returns zero matches.
Braintrust docs status
not_found — AI21 is not listed on the Braintrust integrations directory or the tracing guide.
Upstream references
- AI21 Python SDK on PyPI: https://pypi.org/project/ai21/
- AI21 Python SDK on GitHub: https://github.com/AI21Labs/ai21-python
- AI21 API reference: https://docs.ai21.com/reference/
- AI21 Chat Completions docs: https://docs.ai21.com/reference/jamba-15-api-ref
- AI21 Embeddings docs: https://docs.ai21.com/reference/embeddings-ref
- AI21 SDK quickstart: https://docs.ai21.com/docs/quickstart
Local repo files inspected
py/src/braintrust/integrations/— noai21/directory exists onmainpy/src/braintrust/wrappers/— no AI21 wrapperpy/noxfile.py— notest_ai21sessionpy/src/braintrust/integrations/__init__.py— AI21 not listed in integration registrypy/src/braintrust/integrations/versioning.py— no AI21 version matrixpy/pyproject.toml— no AI21 entries in[tool.braintrust.matrix]- Full repo grep for "ai21" across
py/src/braintrust/— zero matches
- Vorherrschende Sprache
- Python
- Sterne
- 21
- Forks
- 23
- Ø Merge
- 19 Std. 23 Min.
- Gemergte PRs (30 T.)
- 97
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus braintrustdata/braintrust-sdk-python
-
feature python
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
braintrustdata/braintrust-sdk-python#868 ·
Maintainer antworten meist innerhalb von 1 Tag
-
auto_instrument() creates duplicate LLM spans for Google ADK Gemini callsEvtl. vergeben @AbhiPrasad hat das heute übernommen. Offenbug python
braintrustdata/braintrust-sdk-python#896 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
new-integration python
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 55/100
braintrustdata/braintrust-sdk-python#854 ·
Maintainer antworten meist innerhalb von 1 Tag
-
new-integration python
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
braintrustdata/braintrust-sdk-python#853 ·
Maintainer antworten meist innerhalb von 1 Tag
-
new-integration python
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 52/100
braintrustdata/braintrust-sdk-python#852 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in braintrustdata/braintrust-sdk-python
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
NVIDIA/earth2studio#1241 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
docs(types): update the collection binding note now that typed collections shipped in pycubrid 1.9.0Offendocumentation priority: low size: S
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
cubrid-lab/sqlalchemy-cubrid#768 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 1 Tag
-
Broken link in index.rstOffendocumentation
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 65/100
ansys/pydpf-core#3547 ·
Maintainer antworten meist innerhalb von 1 Tag
-
good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
OktoLabsAI/okto-pulse#114 ·
Maintainer antworten meist innerhalb von 1 Tag