Metadata-Version: 2.3
Name: jbai-client
Version: 2026.2.32
Summary: Auto-generated JBAI API python client
Author: JetBrains
Requires-Python: >=3.9
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: httpx (>=0.28.1,<1)
Requires-Dist: pydantic (>=2.11.10,<3.0.0)
Description-Content-Type: text/markdown

# JetBrains AI API client

## Installation

```shell
pip install jbai-client
```

## Usage examples

Create the client:
```python
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:
```python
response = client.get_llm_profiles_v9()
for profile in response.profiles:
    print(profile)
```

Use LLM chat:
```python
# 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:
```python
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:
```python
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)):
```python
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](./MODELS.md)

