> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sunbird.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Sunflower Chat

> Build conversational AI with the Sunflower model

Sunflower is Sunbird AI's large language model, fine-tuned for 20+ Ugandan languages and cultural context. It provides conversational AI through an **OpenAI-compatible** endpoint: `POST /tasks/chat/completions`.

Because the request and response formats mirror the OpenAI Chat Completions API, you can move between the OpenAI API and the Sunbird API by changing only the base URL and API key.

<Warning>
  **Deprecated:** `POST /tasks/sunflower_inference` and `POST /tasks/sunflower_simple` are deprecated and will be removed in a future release. Use `POST /tasks/chat/completions` instead — a single instruction is just a request with one user message.
</Warning>

## Chat Completion

### Example Request

<CodeGroup>
  ```python Python theme={null}
  import requests

  url = "https://api.sunbird.ai/tasks/chat/completions"

  headers = {
      "accept": "application/json",
      "Authorization": "Bearer <your-access-token>",
      "Content-Type": "application/json",
  }

  payload = {
      "model": "Sunbird/Sunflower-14B",
      "messages": [
          {"role": "user", "content": "Good morning, what is the weather today?"}
      ],
      "temperature": 0.3,
  }

  response = requests.post(url, headers=headers, json=payload)
  print(response.status_code)
  print(response.json())
  ```
</CodeGroup>

### Response

```json theme={null}
{
  "id": "chatcmpl-8f14e45fceea167a5a36dedd4bea2543",
  "object": "chat.completion",
  "created": 1718000000,
  "model": "Sunbird/Sunflower-14B",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I'm glad you're up! While I can't provide real-time weather updates, I can help you understand weather forecasts or explain common weather patterns in Uganda."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 22,
    "completion_tokens": 47,
    "total_tokens": 69
  }
}
```

## Using the OpenAI SDK

Because the endpoint is OpenAI-compatible, the official OpenAI Python SDK works out of the box — just point `base_url` at `https://api.sunbird.ai/tasks`:

```python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="<your-access-token>",
    base_url="https://api.sunbird.ai/tasks",
)

completion = client.chat.completions.create(
    model="Sunbird/Sunflower-14B",
    messages=[
        {
            "role": "user",
            "content": "translate from english to luganda: i am very hungry they should serve food in time",
        }
    ],
    temperature=0.1,
)

print(completion.choices[0].message.content)
# Ndi muyala nnyo, emmere erina okugabibwa mu budde.
```

## Multi-turn Conversations

Maintain context by sending the running message history. Each message has a `role` and `content`:

* **system**: Sets the behavior and persona of the AI. When omitted, a default Sunflower system message is applied.
* **user**: The input from the human user.
* **assistant**: A previous response from the AI (used for history).

```python theme={null}
payload = {
    "model": "Sunbird/Sunflower-14B",
    "messages": [
        {"role": "system", "content": "You are a helpful multilingual assistant."},
        {"role": "user", "content": "Translate 'hello' to Luganda."},
        {"role": "assistant", "content": "'Hello' is 'Gyebaleko'."},
        {"role": "user", "content": "And to Acholi?"},
    ],
}
```

## Streaming

Set `"stream": true` to receive Server-Sent Events in OpenAI `chat.completion.chunk` format, terminated by `data: [DONE]`. With the OpenAI SDK:

```python theme={null}
stream = client.chat.completions.create(
    model="Sunbird/Sunflower-14B",
    messages=[{"role": "user", "content": "Tell me about Uganda."}],
    stream=True,
)

for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
```

## Supported Parameters

| Parameter     | Description                             |
| :------------ | :-------------------------------------- |
| `model`       | Only `Sunbird/Sunflower-14B`.           |
| `messages`    | The conversation history.               |
| `temperature` | 0.0–2.0, default 0.3.                   |
| `max_tokens`  | Maximum tokens to generate.             |
| `top_p`       | Nucleus sampling.                       |
| `stop`        | Stop sequence(s).                       |
| `stream`      | Stream the response as SSE when `true`. |
