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

# Generate a response

> Use the MKA1 API Responses resource to generate text, send structured messages, and continue multi-turn exchanges.

Use the Responses resource when you want the MKA1 API to return text.
Start with a plain string for simple prompts.
Use message items when you need explicit roles or conversation state.

## Send a simple prompt

Pass a string in `input` for a single-turn request.
The response includes generated text in `output_text`.

<CodeGroup>
  ```bash CLI theme={null}
  mka1 llm responses create \
    --model auto \
    --input '"Write a one-sentence summary of the MKA1 API."' \
    -H 'X-On-Behalf-Of: <end-user-id>'
  ```

  ```ts MKA1 SDK theme={null}
  import { SDK } from '@meetkai/mka1';

  const mka1 = new SDK({
    bearerAuth: `Bearer ${YOUR_API_KEY}`,
  });

  const result = await mka1.llm.responses.create({
    xOnBehalfOf: '<end-user-id>', // optional — attribute the request to one of your end users
    responsesCreateRequest: {
      model: 'auto',
      input: 'Write a one-sentence summary of the MKA1 API.',
    },
  });
  ```

  ```ts OpenAI SDK theme={null}
  import OpenAI from 'openai';

  const openai = new OpenAI({
    apiKey: '<mka1-api-key>',
    baseURL: 'https://apigw.mka1.com/api/v1/llm/',
    defaultHeaders: { 'X-On-Behalf-Of': '<end-user-id>' },
  });

  const response = await openai.responses.create({
    model: 'auto',
    input: 'Write a one-sentence summary of the MKA1 API.',
    stream: false,
  });
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;
  using MeetKai.MKA1.Types.Components;

  var sdk = new SDK(bearerAuth: "Bearer YOUR_API_KEY");

  var res = await sdk.Llm.Responses.CreateAsync(new ResponsesCreateRequest()
  {
      Model = "auto",
      Input = ResponsesCreateRequestInput.CreateStr(
          "Write a one-sentence summary of the MKA1 API."),
  });
  ```

  ```python Python SDK theme={null}
  from meetkai_mka1 import SDK

  sdk = SDK(bearer_auth="Bearer YOUR_API_KEY")

  res = sdk.llm.responses.create(
      model="auto",
      input="Write a one-sentence summary of the MKA1 API.",
      http_headers={"X-On-Behalf-Of": "<end-user-id>"},
  )
  ```

  ```bash bash theme={null}
  curl https://apigw.mka1.com/api/v1/llm/responses \
    --request POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>' \
    --data '{
      "model": "auto",
      "input": "Write a one-sentence summary of the MKA1 API."
    }'
  ```
</CodeGroup>

If you are not acting for an end user, omit `X-On-Behalf-Of`.

## Add instructions

Use `instructions` to define behavior before the model sees the user input.
Keep instructions short and specific.

<CodeGroup>
  ```bash CLI theme={null}
  mka1 llm responses create \
    --model auto \
    --instructions 'You are a support assistant. Reply in plain English. Keep answers under 80 words.' \
    --input '"Explain what embeddings are used for."'
  ```

  ```ts MKA1 SDK theme={null}
  const result = await mka1.llm.responses.create({
    responsesCreateRequest: {
      model: 'auto',
      instructions: 'You are a support assistant. Reply in plain English. Keep answers under 80 words.',
      input: 'Explain what embeddings are used for.',
    },
  });
  ```

  ```ts OpenAI SDK theme={null}
  const response = await openai.responses.create({
    model: 'auto',
    instructions: 'You are a support assistant. Reply in plain English. Keep answers under 80 words.',
    input: 'Explain what embeddings are used for.',
    stream: false,
  });
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;
  using MeetKai.MKA1.Types.Components;

  var sdk = new SDK(bearerAuth: "Bearer YOUR_API_KEY");

  var res = await sdk.Llm.Responses.CreateAsync(new ResponsesCreateRequest()
  {
      Model = "auto",
      Instructions = "You are a support assistant. Reply in plain English. Keep answers under 80 words.",
      Input = ResponsesCreateRequestInput.CreateStr("Explain what embeddings are used for."),
  });
  ```

  ```python Python SDK theme={null}
  res = sdk.llm.responses.create(
      model="auto",
      instructions="You are a support assistant. Reply in plain English. Keep answers under 80 words.",
      input="Explain what embeddings are used for.",
  )
  ```

  ```bash bash theme={null}
  curl https://apigw.mka1.com/api/v1/llm/responses \
    --request POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>' \
    --data '{
      "model": "auto",
      "instructions": "You are a support assistant. Reply in plain English. Keep answers under 80 words.",
      "input": "Explain what embeddings are used for."
    }'
  ```
</CodeGroup>

## Send structured messages

Use an array of message items in `input` when you want explicit roles.
Each message item uses `type`, `role`, and `content`.

<CodeGroup>
  ```bash CLI theme={null}
  mka1 llm responses create --body '{
    "model": "auto",
    "input": [
      { "type": "message", "role": "developer", "content": "Answer as a technical writer. Keep the reply concise." },
      { "type": "message", "role": "user", "content": "Draft a short product update about faster response times." }
    ]
  }'
  ```

  ```ts MKA1 SDK theme={null}
  const result = await mka1.llm.responses.create({
    responsesCreateRequest: {
      model: 'auto',
      input: [
        { type: 'message', role: 'developer', content: 'Answer as a technical writer. Keep the reply concise.' },
        { type: 'message', role: 'user', content: 'Draft a short product update about faster response times.' },
      ],
    },
  });
  ```

  ```ts OpenAI SDK theme={null}
  const response = await openai.responses.create({
    model: 'auto',
    input: [
      { type: 'message', role: 'developer', content: 'Answer as a technical writer. Keep the reply concise.' },
      { type: 'message', role: 'user', content: 'Draft a short product update about faster response times.' },
    ],
    stream: false,
  });
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;
  using MeetKai.MKA1.Types.Components;

  var sdk = new SDK(bearerAuth: "Bearer YOUR_API_KEY");

  var res = await sdk.Llm.Responses.CreateAsync(new ResponsesCreateRequest()
  {
      Model = "auto",
      Input = ResponsesCreateRequestInput.CreateArrayOfItem(new List<Item>
      {
          Item.CreateInputMessage(new InputMessage()
          {
              Role = InputMessageRole.Developer,
              Content = InputMessageContent1.CreateStr(
                  "Answer as a technical writer. Keep the reply concise."),
          }),
          Item.CreateInputMessage(new InputMessage()
          {
              Role = InputMessageRole.User,
              Content = InputMessageContent1.CreateStr(
                  "Draft a short product update about faster response times."),
          }),
      }),
  });
  ```

  ```python Python SDK theme={null}
  res = sdk.llm.responses.create(
      model="auto",
      input=[
          {"type": "message", "role": "developer", "content": "Answer as a technical writer. Keep the reply concise."},
          {"type": "message", "role": "user", "content": "Draft a short product update about faster response times."},
      ],
  )
  ```

  ```bash bash theme={null}
  curl https://apigw.mka1.com/api/v1/llm/responses \
    --request POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>' \
    --data '{
      "model": "auto",
      "input": [
        { "type": "message", "role": "developer", "content": "Answer as a technical writer. Keep the reply concise." },
        { "type": "message", "role": "user", "content": "Draft a short product update about faster response times." }
      ]
    }'
  ```
</CodeGroup>

This pattern is useful when you want the request body to carry the message history directly.

## Continue a multi-turn exchange

Use `previous_response_id` to continue from an earlier response without resending the full history.

<CodeGroup>
  ```bash CLI theme={null}
  mka1 llm responses create \
    --model auto \
    --previous-response-id resp_123 \
    --input '"Now turn that into an email subject line."'
  ```

  ```ts MKA1 SDK theme={null}
  const second = await mka1.llm.responses.create({
    responsesCreateRequest: {
      model: 'auto',
      previousResponseId: 'resp_123',
      input: 'Now turn that into an email subject line.',
    },
  });
  ```

  ```ts OpenAI SDK theme={null}
  const second = await openai.responses.create({
    model: 'auto',
    previous_response_id: 'resp_123',
    input: 'Now turn that into an email subject line.',
    stream: false,
  });
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;
  using MeetKai.MKA1.Types.Components;

  var sdk = new SDK(bearerAuth: "Bearer YOUR_API_KEY");

  // First request
  var first = await sdk.Llm.Responses.CreateAsync(new ResponsesCreateRequest()
  {
      Model = "auto",
      Input = ResponsesCreateRequestInput.CreateStr("Write a one-line product tagline."),
  });

  // Second request: continue from the first response
  var second = await sdk.Llm.Responses.CreateAsync(new ResponsesCreateRequest()
  {
      Model = "auto",
      PreviousResponseId = first.Id,
      Input = ResponsesCreateRequestInput.CreateStr("Now turn that into an email subject line."),
  });
  ```

  ```python Python SDK theme={null}
  res = sdk.llm.responses.create(
      model="auto",
      previous_response_id="resp_123",
      input="Now turn that into an email subject line.",
  )
  ```

  ```bash bash theme={null}
  curl https://apigw.mka1.com/api/v1/llm/responses \
    --request POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>' \
    --data '{
      "model": "auto",
      "previous_response_id": "resp_123",
      "input": "Now turn that into an email subject line."
    }'
  ```
</CodeGroup>

If you need a reusable conversation container, create one with the Conversations resource and then pass the conversation ID in `conversation`.

<CodeGroup>
  ```bash CLI theme={null}
  # Create a conversation
  mka1 llm conversations create --body '{
    "metadata": { "session_id": "web-42" }
  }'

  # Use the conversation in a response request
  mka1 llm responses create \
    --model auto \
    --conversation conv_123 \
    --input '"What should I ask next to refine this draft?"'
  ```

  ```ts MKA1 SDK theme={null}
  const conv = await mka1.llm.conversations.create({
    createConversationRequest: {
      metadata: { session_id: 'web-42' },
    },
  });

  const result = await mka1.llm.responses.create({
    responsesCreateRequest: {
      model: 'auto',
      conversation: conv.id,
      input: 'What should I ask next to refine this draft?',
    },
  });
  ```

  ```ts OpenAI SDK theme={null}
  const conv = await openai.conversations.create({
    metadata: { session_id: 'web-42' },
  });

  const response = await openai.responses.create({
    model: 'auto',
    conversation: conv.id,
    input: 'What should I ask next to refine this draft?',
    stream: false,
  });
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;
  using MeetKai.MKA1.Types.Components;

  var sdk = new SDK(bearerAuth: "Bearer YOUR_API_KEY");

  var conv = await sdk.Llm.Conversations.CreateAsync(body: new CreateConversationRequest()
  {
      Metadata = new Dictionary<string, string> { { "session_id", "web-42" } },
  });
  ```

  ```python Python SDK theme={null}
  conv = sdk.llm.conversations.create(
      metadata={"session_id": "web-42"},
  )

  res = sdk.llm.responses.create(
      model="auto",
      conversation=conv.id,
      input="What should I ask next to refine this draft?",
  )
  ```

  ```bash bash theme={null}
  # Create conversation
  curl https://apigw.mka1.com/api/v1/llm/conversations \
    --request POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>' \
    --data '{
      "metadata": { "session_id": "web-42" }
    }'

  # Use conversation in a response request
  curl https://apigw.mka1.com/api/v1/llm/responses \
    --request POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>' \
    --data '{
      "model": "auto",
      "conversation": "conv_123",
      "input": "What should I ask next to refine this draft?"
    }'
  ```
</CodeGroup>

See the Conversations and Responses pages in the [API Reference](/api-reference/introduction) for the full resource workflow.

## Stream text as it is generated

Set `stream` to `true` to receive server-sent events instead of waiting for the full response.

<CodeGroup>
  ```bash CLI theme={null}
  mka1 llm responses create \
    --model auto \
    --input '"Write three release notes bullets for our docs update."' \
    --stream
  ```

  ```ts MKA1 SDK theme={null}
  import { CreateAcceptEnum } from '@meetkai/mka1/sdk/responses';

  const result = await mka1.llm.responses.create({
    responsesCreateRequest: {
      model: 'auto',
      input: 'Write three release notes bullets for our docs update.',
      stream: true,
    },
  }, { acceptHeaderOverride: CreateAcceptEnum.textEventStream });
  ```

  ```ts OpenAI SDK theme={null}
  const stream = await openai.responses.create({
    model: 'auto',
    input: 'Write three release notes bullets for our docs update.',
    stream: true,
  });

  for await (const event of stream) {
    if (event.type === 'response.output_text.delta') {
      process.stdout.write(event.delta);
    }
  }
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;
  using MeetKai.MKA1.Types.Components;

  var sdk = new SDK(bearerAuth: "Bearer YOUR_API_KEY");

  var res = await sdk.Llm.Responses.CreateAsync(new ResponsesCreateRequest()
  {
      Model = "auto",
      Input = ResponsesCreateRequestInput.CreateStr(
          "Write three release notes bullets for our docs update."),
      Stream = true,
  });
  ```

  ```python Python SDK theme={null}
  stream = sdk.llm.responses.create(
      model="auto",
      input="Write three release notes bullets for our docs update.",
      stream=True,
  )

  for event in stream:
      if event.data.type == "response.output_text.delta":
          print(event.data.delta, end="", flush=True)
  ```

  ```bash bash theme={null}
  curl https://apigw.mka1.com/api/v1/llm/responses \
    --request POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>' \
    --data '{
      "model": "auto",
      "input": "Write three release notes bullets for our docs update.",
      "stream": true
    }'
  ```
</CodeGroup>

Use streaming when you want to render partial output as it arrives.

## Next steps

* Review the [API overview](/api-reference/introduction) for authentication and base URL details
* See [background responses](/docs/background-responses) when you need to offload long-running work and poll or stream for results
* See [manage conversations](/docs/conversations) to organize multi-turn exchanges into reusable conversation containers
* See [manage agents](/docs/managing-agents) when you want reusable agent definitions and persisted runs
