Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

[bot] Add AI21 Labs Python SDK integration for chat completions and embeddings instrumentation (54,424 weekly downloads)

Aberta
#442 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
48/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Pouca atividade
Stack de tecnologia
python
Domínio
observability

Direção de pesquisa

Comece comparando os padrões de integração de OpenAI ou Mistral em py/src/braintrust/integrations/ e, em seguida, inspecione py/noxfile.py e os arquivos de registro e versionamento da integração mencionados na issue. Implemente suporte para chat completions síncronas e assíncronas, streaming e embeddings, incluindo os metadados documentados, e adicione os testes, o registro, a entrada de versão e a entrada na matriz de dependências da integração.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bot-automation new-integration

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] in py/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

Local repo files inspected

  • py/src/braintrust/integrations/ — no ai21/ directory exists on main
  • py/src/braintrust/wrappers/ — no AI21 wrapper
  • py/noxfile.py — no test_ai21 session
  • py/src/braintrust/integrations/__init__.py — AI21 not listed in integration registry
  • py/src/braintrust/integrations/versioning.py — no AI21 version matrix
  • py/pyproject.toml — no AI21 entries in [tool.braintrust.matrix]
  • Full repo grep for "ai21" across py/src/braintrust/ — zero matches
Linguagem predominante
Python
Estrelas
21
Forks
23
Merge médio
20h 8min
PRs com merge (30d)
94

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de braintrustdata/braintrust-sdk-python

Todas as issues de braintrustdata/braintrust-sdk-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.