Skip to content

Feature request: expose knowledge base reranking_config (bge-reranker-v2-m3) in the SDK #95

@HesselTjeerdsma

Description

@HesselTjeerdsma

Summary

The DigitalOcean Gradient REST API supports configuring a reranker model on a knowledge base via a reranking_config object on the create/update knowledge base endpoints, but the current Python SDK (3.12.1, generated from the Stainless OpenAPI spec) does not expose this field. As a result, SDK users have to drop down to raw HTTP calls to enable reranking, which defeats the purpose of using the typed SDK.

Please regenerate / update the SDK so reranking_config is available on the knowledge base create and update methods.

What exists in the REST API today

The official digitalocean/openapi spec already documents reranking_config in the gen-ai knowledge base examples:

Example payload from genai_create_knowledge_base.yml:

{
  "name": "kb-api-create",
  "embedding_model_uuid": "05700391-7aa8-11ef-bf8f-4e013e2ddde4",
  "project_id": "37455431-84bd-4fa2-94cf-e8486f8f8c5e",
  "database_id": "abf1055a-745d-4c24-a1db-1959ea819264",
  "region": "tor1",
  "reranking_config": {
    "enabled": true,
    "model": "bge-reranker-v2-m3"
  }
}

This matches the reranking feature described in the DigitalOcean blog post "Smarter Knowledge Bases for Smarter AI Agents", which announced support for the BAAI bge-reranker-v2-m3 reranker.

What is missing in the SDK

In gradient 3.12.1 (and on main at time of writing):

  • grep -ri rerank across the SDK source returns zero matches (verified via GitHub code search: q=rerank repo:digitalocean/gradient-python → 0 results).
  • gradient.types.api_retrieval_method.APIRetrievalMethod only contains:
    • RETRIEVAL_METHOD_UNKNOWN
    • RETRIEVAL_METHOD_REWRITE
    • RETRIEVAL_METHOD_STEP_BACK
    • RETRIEVAL_METHOD_SUB_QUERIES
    • RETRIEVAL_METHOD_NONE
  • The knowledge_bases.create(...) / knowledge_bases.update(...) methods do not accept a reranking_config parameter, and there is no RerankingConfig / KnowledgeBaseRerankingConfig model type exported.

Proposed change

  1. Add a reranking_config parameter to:
    • client.gen_ai.knowledge_bases.create(...)
    • client.gen_ai.knowledge_bases.update(...)
  2. Add a corresponding typed model, e.g. KnowledgeBaseRerankingConfig, with fields:
    • enabled: bool
    • model: Literal["bge-reranker-v2-m3", ...] (or str if more models will be added)
  3. Expose reranking_config on the response model returned by knowledge_bases.retrieve(...) so callers can read the current state.
  4. If reranking ever becomes configurable per-agent (rather than per-KB), expose it there too — but per the current spec it lives on the KB.

Since the SDK is generated by Stainless from the OpenAPI spec, this likely requires updating the gen-ai schema in digitalocean/openapi to declare reranking_config as a real schema (not just an example), and then regenerating.

Why this matters

Without SDK support, every user who wants to enable reranking has to:

  • Construct a raw httpx/requests call,
  • Manage auth headers separately from the SDK client,
  • Forgo type checking and IDE autocompletion on a feature DO is actively marketing.

This is a small, additive change that significantly improves the SDK's coverage of the Gradient AI Platform.

Environment

  • SDK: gradient 3.12.1 (latest on PyPI as of 2026-03-25)
  • Python: 3.12
  • API: https://api.digitalocean.com/v2/gen-ai/knowledge_bases

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions