Generate Text

Text Generation

Use chat_completions_create() to generate text responses from AI models.

Copy

from mira_network import MiraClient

async def generate_text():
    async with MiraClient(api_key="your-api-key") as client:
        response = await client.chat_completions_create(
            model="your-chosen-model",
            messages=[
                {"role": "user", "content": "What is the capital of France?"}
            ]
        )
        print(response["choices"][0]["message"]["content"])

arrow-up-rightStreaming Responses

For real-time text generation:

Copy

arrow-up-rightMulti-turn Conversations

Handle complex dialogues:

Copy

arrow-up-rightError Handling

Implement robust error handling:

Copy

arrow-up-rightCustom Node Configuration

For specialized deployments:

Copy

arrow-up-rightMessage Structure

Core components of a message:

Copy

Last updated