> For the complete documentation index, see [llms.txt](https://docs.nebulablock.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nebulablock.com/products/serverless-inference/text-generation.md).

# Text Generation

Generate text and hold conversations with Nebula Block's chat models using the OpenAI-compatible API.

Use these models to generate text, whether it's to review code, write a story, etc.

## Models available

Nebula Block serves dozens of text and multimodal chat models — including the latest from Anthropic, OpenAI, Google, DeepSeek, Qwen, Moonshot, xAI, and Z.ai. The [Model Catalog](/products/serverless-inference/model-catalog.md#text-generation-and-multimodal-chat) has the full list with context lengths and model IDs.

A few widely used ones:

| Model            | Model ID                            |
| ---------------- | ----------------------------------- |
| DeepSeek-V3.2    | `deepseek-ai/DeepSeek-V3.2`         |
| Claude Sonnet 5  | `anthropic/claude-sonnet-5`         |
| GPT-5.6          | `openai/gpt-5.6-terra`              |
| Gemini 3.7 Flash | `gemini/gemini-3.7-flash`           |
| Qwen3.5-Plus     | `Qwen/Qwen3.5-Plus`                 |
| Llama 3.3 70B    | `meta-llama/Llama-3.3-70B-Instruct` |

> **Note:** Model availability changes often. Call [`GET /v1/models`](/api-reference/inference-api/list-models.md) for the authoritative list at runtime rather than hard-coding one.

## Using the Models

1. Sign in to the [console](https://console.nebulablock.com) and make sure you have credit.
2. Open [**Serverless**](https://console.nebulablock.com/serverless) and pick a model.
3. Set your parameters, type your prompt, and send it.

The parameters you can tweak are outlined below:

* Messages: The current dialogue between the user and the model.
* System Prompt: Set of instructions, guidelines, and contextual information, which tell the AI how to respond to the queries.
* Output Length: The maximum number of tokens that will be generated for each response.
* Temperature: Temperature controls randomness. Higher values increase diversity.
* Top P: A higher value will result in more diverse outputs, while a lower value will result in more repetitive outputs.
* Stream: If set to `true`, the response will be streamed in chunks. If False, the entire generation will be returned in one response.

### Through API Endpoint

This option is to use our API endpoint directly in your projects. Below are some code snippets to get you started!

> **NOTE:** Don't forget to use **your** API key. See the [API Reference](/api-reference/authentication.md) and the [Overview](/account/api-keys.md) for more details on authentication.

#### Using cURL

```bash
curl -X POST "https://inference.nebulablock.com/v1/chat/completions" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $NEBULA_API_KEY" \
    --data-raw '{
        "messages": [
	  {"role":"user","content":"Is Montreal a thriving hub for the AI industry?"}
	],
        "model": "meta-llama/Llama-3.3-70B-Instruct",
        "max_tokens": null, 
        "temperature": 1,
        "top_p": 0.9,
        "stream": false
    }'
```

#### Using Python

```python
import requests 
import os
 
url = "https://inference.nebulablock.com/v1/chat/completions"

headers = { 
    "Content-Type": "application/json", 
    "Authorization": f"Bearer {os.environ.get('NEBULA_API_KEY')}" 
} 
 
data = {
    "messages":[
		{"role":"user","content":"Is Montreal a thriving hub for the AI industry?"}
	],
    "model":"meta-llama/Llama-3.3-70B-Instruct",
    "max_tokens":None,
    "temperature":1,
    "top_p":0.9,
    "stream":False
}

response = requests.post(url, headers=headers, json=data) 
print(response.json())
```

#### Using JavaScript

```javascript
const url = "https://inference.nebulablock.com/v1/chat/completions";

const headers = {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.NEBULA_API_KEY}`
};

const data = {
    messages: [
        { role: "user", content: "Is Montreal a thriving hub for the AI industry?" }
    ],
    model: "meta-llama/Llama-3.3-70B-Instruct",
    max_tokens: null,
    temperature: 1,
    top_p: 0.9,
    stream: false
};

fetch(url, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(data)
})
    .then(response => response.json())
    .then(data => {
        console.log(JSON.stringify(data, null, 2));
    })
    .catch(error => console.error('Error:', error));
```

#### Selecting a Model

To specify the desired model, use this mapping for the `model_name`:

* DeepSeek-R1-0528 (free):

  ```python
  deepseek-ai/DeepSeek-R1-0528-Free
  ```
* DeepSeek-V3-0324 (free):

  ```python
  deepseek-ai/DeepSeek-V3-0324-Free
  ```
* DeepSeek-V3-0324:

  ```python
  deepseek-ai/DeepSeek-V3-0324
  ```
* DeepSeek-R1 (free):

  ```python
  deepseek-ai/DeepSeek-R1-Free
  ```
* DeepSeek-R1-0528:

  ```python
  deepseek-ai/DeepSeek-R1-0528
  ```
* DeepSeek-R1:

  ```python
  deepseek-ai/DeepSeek-R1
  ```
* Llama3.3-70B:

  ```python
  meta-llama/Llama-3.3-70B-Instruct
  ```
* Qwen-QwQ-32B:

  ```python
  Qwen/QwQ-32B
  ```

#### Response Example

A successful generation response (non-streaming) will contain a `chat.completion` object, and should look like this:

```json
{
    "id": "chatcmpl-ec0014bc38e2cad1e45d47f7f01f6569",
    "created": 1740432179,
    "model": "meta-llama/Llama-3.3-70B-Instruct",
    "object": "chat.completion",
    "system_fingerprint": null,
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "content": "Yes! Montreal is the home of cutting edge ... research.",
                "role": "assistant",
                "tool_calls": null,
                "function_call": null
            }
        }
    ],
    "usage": {
        "completion_tokens": 695,
        "prompt_tokens": 42,
        "total_tokens": 737,
        "completion_tokens_details": null,
        "prompt_tokens_details": null
    },
    "service_tier": null,
    "prompt_logprobs": null
}
```

This represents the entire generated response from the inference. Alternatively, the streaming option (`stream: true` in the request body) will return several responses, each containing a `chat.completion.chunk` object, and will look like this:

```json
{
    "id": "chatcmpl-289eb1f670a58c5cde47ddb634aad595",
    "created": 1740432271,
    "model": "meta-llama/Llama-3.3-70B-Instruct",
    "object": "chat.completion.chunk",
    "choices": [
        {
            "index": 0,
            "delta": {
                "content": " everyone"
            }
        }
    ]
}
{ 
  ...
}
...
```

where the content of each response will contain the generated token. These tokens put together form the complete response.

Feel free to explore refer to the [API Reference](/api-reference/inference-api/chat-completions.md) for more details.\
cat Inference\_Models/Text\_Generation.md
