Skip to main content

Auto-generated JBAI API python client

Project description

JetBrains AI API client

Installation

pip install jbai-client

Usage examples

Create the client:

import os

from jbai_client import JbaiPlatformClient, JbaiAuthType, JbaiEndpoint

client = JbaiPlatformClient(
    endpoint=JbaiEndpoint.STAGING,
    auth_type=JbaiAuthType.USER,
    api_key=os.getenv("JBAI_TOKEN"),
)

LLM API

Get the list of LLM profiles:

response = client.get_llm_profiles_v9()
for profile in response.profiles:
    print(profile)

Use LLM chat:

# noinspection PyTypeChecker
from jbai_client.models import ChatModelsStreamV9Request, LLMChatUserMessage, V5LLMChat

for response in client.post_llm_chat_stream_v9(
        request=ChatModelsStreamV9Request(
            prompt="test",
            profile="openai-gpt-4",
            chat=V5LLMChat(
                messages=[
                    LLMChatUserMessage(content="Tell me a joke about programmers"),
                ]
            ),
        )
):
    print(response)

Use AsyncJbaiPlatformClient for asynchronous execution:

import asyncio
import os

from jbai_client import AsyncJbaiPlatformClient, JbaiAuthType, JbaiEndpoint
from jbai_client.models import ChatModelsStreamV9Request, LLMChatUserMessage, V5LLMChat

client = AsyncJbaiPlatformClient(
    endpoint=JbaiEndpoint.STAGING,
    auth_type=JbaiAuthType.USER,
    api_key=os.getenv("JBAI_TOKEN"),
)

async def main():
    # noinspection PyTypeChecker
    async for response in client.post_llm_chat_stream_v9(
            request=ChatModelsStreamV9Request(
                prompt="test",
                profile="openai-gpt-4",
                chat=V5LLMChat(
                    messages=[
                        LLMChatUserMessage(content="Tell me a joke about programmers"),
                    ]
                ),
            )
    ):
        print(response)

asyncio.run(main())

Tasks API

Get tasks roster:

response = client.get_task_roster()
for task in response.ids:
    print(task)

Call a task (optionally specify a task tag via custom header (valid only for STAGING)):

from jbai_client import JbaiHeader
from jbai_client.models import TaskAPIStreamV5TextImproveShortenRequest

# noinspection PyTypeChecker
for response in client.text_improve_shorten_v5(
        TaskAPIStreamV5TextImproveShortenRequest(
            parameters={
                "text": "This is a simple example sentence that could be made shorter and clearer.",
                "lang": "en",
            }
        ),
        headers={
            JbaiHeader.GRAZIE_TASK_TAG: "openai-chat-gpt"
        },
):
    print(response)

P.S. Most modern IDEs support auto-import functionality, which can simplify the discovery and import of data model classes.

Data models documentation

See MODELS.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jbai_client-2026.2.32.tar.gz (68.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jbai_client-2026.2.32-py3-none-any.whl (447.1 kB view details)

Uploaded Python 3

File details

Details for the file jbai_client-2026.2.32.tar.gz.

File metadata

  • Download URL: jbai_client-2026.2.32.tar.gz
  • Upload date:
  • Size: 68.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.18 Linux/5.15.0-1084-aws

File hashes

Hashes for jbai_client-2026.2.32.tar.gz
Algorithm Hash digest
SHA256 9b09f0432e8e9c78bcb8d787499231f9919ed0a80d7b1e31299ccd79a4ac5402
MD5 a2817191a9509f14148200283f76d05e
BLAKE2b-256 67f48093dc4f36e8d2c0e07a28b70cbccf65a7124f4644fad3912e14c3d33286

See more details on using hashes here.

File details

Details for the file jbai_client-2026.2.32-py3-none-any.whl.

File metadata

  • Download URL: jbai_client-2026.2.32-py3-none-any.whl
  • Upload date:
  • Size: 447.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.18 Linux/5.15.0-1084-aws

File hashes

Hashes for jbai_client-2026.2.32-py3-none-any.whl
Algorithm Hash digest
SHA256 a74a195563e37c48faaf23bb13885658d0c0c5c7fcb2ff377bc019fded8202fe
MD5 ac885cb4951a377c6a2fe25fb6b01560
BLAKE2b-256 7790b2482b36b46d91602dfba2a9adfd00922f15c133132f89ec3769aeba910c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page