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

# Use Modellix LLM with Microsoft Agent Framework

> Point Microsoft Agent Framework at Modellix with OpenAIChatCompletionClient base_url, a Modellix API key, and provider/name model IDs.

Use [Microsoft Agent Framework](https://learn.microsoft.com/en-us/agent-framework/overview/?pivots=programming-language-python) against the Modellix LLM gateway. Python clients accept a `base_url` for [any OpenAI-compatible endpoint](https://learn.microsoft.com/en-us/agent-framework/integrations/openai-endpoints?pivots=programming-language-python). Point that URL at Chat Completions (or Responses) on `https://llm.modellix.ai/v1`.

<Note>
  This page covers **LLM text** only (`https://llm.modellix.ai`).

  Modellix model IDs are `provider/name` (for example `openai/gpt-5.5`). Pass that full string as `model`. See [Models & Pricing](/llm/overview#models-and-pricing).

  Microsoft documents that third-party (non-Azure Direct) models are used at your own risk under their Product Terms. Review data sharing and compliance for your deployment.
</Note>

## Set Up Microsoft Agent Framework

<Steps>
  <Step title="Install the Framework">
    Python:

    ```bash theme={null}
    pip install agent-framework
    ```

    .NET (OpenAI integration packages; versions may be prerelease):

    ```bash theme={null}
    dotnet add package Microsoft.Agents.AI.OpenAI --prerelease
    dotnet add package OpenAI
    ```
  </Step>

  <Step title="Set Credentials">
    Create a Modellix API key in the [console](https://modellix.ai/console/api-key):

    ```bash theme={null}
    export OPENAI_API_KEY="mdlx-xxxxxxxx"
    export OPENAI_BASE_URL="https://llm.modellix.ai/v1"
    ```

    | Setting                        | Value                                        |
    | ------------------------------ | -------------------------------------------- |
    | `OPENAI_API_KEY` / `api_key`   | Modellix API Key                             |
    | `OPENAI_BASE_URL` / `base_url` | `https://llm.modellix.ai/v1` (include `/v1`) |
    | `model`                        | Exact Modellix Model ID (`provider/name`)    |

    <Warning>
      Agent Framework does **not** load `.env` files automatically. Call `load_dotenv()` yourself, export variables in the shell, or pass `api_key` / `base_url` in code. Do not use the media host (`https://api.modellix.ai`).
    </Warning>
  </Step>

  <Step title="Create an Agent with Chat Completions (Recommended)">
    Use `OpenAIChatCompletionClient` for maximum compatibility with OpenAI-compatible gateways:

    ```python theme={null}
    import asyncio
    from agent_framework.openai import OpenAIChatCompletionClient

    async def main() -> None:
        agent = OpenAIChatCompletionClient(
            base_url="https://llm.modellix.ai/v1",
            api_key="mdlx-xxxxxxxx",  # or rely on OPENAI_API_KEY
            model="openai/gpt-5.5",
        ).as_agent(
            name="Assistant",
            instructions="You are a concise coding assistant.",
        )

        result = await agent.run("Introduce yourself in one sentence.")
        print(result)

    asyncio.run(main())
    ```

    You can omit `base_url` / `api_key` in the constructor when `OPENAI_BASE_URL` and `OPENAI_API_KEY` are set in the environment.

    Change `model` to any catalog ID (`anthropic/claude-sonnet-5`, `google/gemini-3.6-flash`, and so on). Traffic still uses Chat Completions on `https://llm.modellix.ai/v1`.
  </Step>

  <Step title="Optional: Responses Client">
    Modellix also exposes [`POST /v1/responses`](/llm/responses). Use `OpenAIChatClient` when you want the Responses path:

    ```python theme={null}
    import asyncio
    from agent_framework.openai import OpenAIChatClient

    async def main() -> None:
        agent = OpenAIChatClient(
            base_url="https://llm.modellix.ai/v1",
            api_key="mdlx-xxxxxxxx",
            model="openai/gpt-5.5",
        ).as_agent(
            name="Assistant",
            instructions="You are a concise coding assistant.",
        )

        result = await agent.run("Say hello in one short sentence.")
        print(result)

        async for chunk in agent.run("Tell a one-line joke.", stream=True):
            if chunk.text:
                print(chunk.text, end="", flush=True)

    asyncio.run(main())
    ```

    Prefer Chat Completions first if tools or streaming behave unexpectedly on Responses through a gateway.
  </Step>

  <Step title="Optional: .NET">
    Point the OpenAI .NET client at Modellix, then create an agent:

    ```csharp theme={null}
    using System.ClientModel;
    using Microsoft.Agents.AI;
    using OpenAI;

    var endpoint = Environment.GetEnvironmentVariable("OPENAI_BASE_URL")
        ?? "https://llm.modellix.ai/v1";
    var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY")
        ?? throw new InvalidOperationException("OPENAI_API_KEY is required.");
    var model = "openai/gpt-5.5";

    AIAgent agent = new OpenAIClient(
            new ApiKeyCredential(apiKey),
            new OpenAIClientOptions { Endpoint = new Uri(endpoint) })
        .GetChatClient(model)
        .AsAIAgent(
            instructions: "You are a concise coding assistant.",
            name: "Assistant");

    Console.WriteLine(await agent.RunAsync("Introduce yourself in one sentence."));
    ```

    Keep `Endpoint` as `https://llm.modellix.ai/v1` and use a full Modellix Model ID.
  </Step>
</Steps>

## Troubleshooting

| Symptom               | Check                                                                       |
| --------------------- | --------------------------------------------------------------------------- |
| 401 / auth errors     | Key is a valid Modellix API key (`OPENAI_API_KEY` or `api_key`)             |
| Model not found / 404 | `model` is a full ID like `openai/gpt-5.5`, not bare `gpt-5.5`              |
| Wrong path            | `base_url` / `OPENAI_BASE_URL` / `Endpoint` is `https://llm.modellix.ai/v1` |
| Env vars ignored      | Framework does not auto-load `.env`; export vars or pass constructor args   |
| Responses failures    | Fall back to `OpenAIChatCompletionClient` (Chat Completions)                |

## Related

* [Microsoft Agent Framework overview](https://learn.microsoft.com/en-us/agent-framework/overview/?pivots=programming-language-python) — agents, harness, workflows
* [OpenAI-compatible endpoints](https://learn.microsoft.com/en-us/agent-framework/integrations/openai-endpoints?pivots=programming-language-python) — `base_url` for Python clients
* [OpenAI SDK](/llm/sdk/openai-sdk) — same `/v1` gateway without the agent harness
* [OpenAI Agents SDK](/llm/sdk/openai-agents) — another OpenAI-compatible agent runtime
* [Models & Pricing](/llm/overview#models-and-pricing) — Model IDs and rates
* [LLM API guide](/llm/api/api) — protocols and curl examples
