[bot] Add AI21 Labs Python SDK integration for chat completions and embeddings instrumentation (54,424 weekly downloads)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- python
- Área
- observability
Línea de trabajo
Empieza comparando los patrones de integración de OpenAI o Mistral en py/src/braintrust/integrations/ y, después, inspecciona py/noxfile.py y los archivos de registro y versionado de la integración indicados en la issue. Implementa cobertura para chat completions síncronas y asíncronas, streaming y embeddings, incluidos los metadatos documentados, y añade las pruebas, el registro, la entrada de versión y la entrada en la matriz de dependencias de la integración.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 21
- Forks
- 23
- Merge medio
- 21 h 8 min
- PR fusionados (30 d)
- 81
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de braintrustdata/braintrust-sdk-python
-
[bot] Anthropic: MCP connector tool calls (`mcp_tool_use`/`mcp_tool_result`) are silently dropped from tool spansPosiblemente ocupada @March-7 la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
braintrustdata/braintrust-sdk-python#797 ·
Los mantenedores suelen responder en 1 día
-
[bot] Google GenAI: streaming responses drop `url_context_metadata` that non-streaming responses preservePosiblemente ocupada @Kayvan-Zahiri la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
braintrustdata/braintrust-sdk-python#774 ·
Los mantenedores suelen responder en 1 día
-
Migrate legacy HTTPConnection callers to the policy-aware Transport incrementallyPosiblemente ocupada @AbhiPrasad la tomó hace 3 días. Abiertopython
braintrustdata/braintrust-sdk-python#839 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
new-integration
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
braintrustdata/braintrust-sdk-python#808 ·
Los mantenedores suelen responder en 1 día
-
new-integration
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
braintrustdata/braintrust-sdk-python#807 ·
Los mantenedores suelen responder en 1 día
Todos los issues de braintrustdata/braintrust-sdk-python
Issues similares
-
feature:LinkChecker
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
digitalfabrik/integreat-cms#4594 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
EleutherAI/lm-evaluation-harness#4319 ·
Los mantenedores suelen responder en 1 día
-
needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
json_params_matcher fails on falsy top-level JSON primitives (0, False, "")Posiblemente ocupada @mayureshsonawane17 la tomó hoy. AbiertoWaiting for: Product Owner
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 5 días