================================================================================
  SindByte MCP Server -- Codex CLI Setup Guide
  Connecting OpenAI Codex CLI to Your Local Endpoint
================================================================================
Date: 2026-04-17
For: SindByte Server v1.9.09

--------------------------------------------------------------------------------
 1. WHAT IS CODEX CLI?
--------------------------------------------------------------------------------
Codex CLI is OpenAI's official terminal-based AI coding assistant.
It is NOT the same as OpenCode CLI or any other tool.

  Official source:   https://github.com/openai/codex
  Install command:   npm install -g @openai/codex
  Config file:       ~/.codex/config.toml
  Auth file:         ~/.codex/auth.json

--------------------------------------------------------------------------------
 2. REQUIRED INFORMATION
--------------------------------------------------------------------------------
  SindByte Base URL:   http://127.0.0.1:8091/v1
  API Key:             sk-sindbyte-local   (or any text -- not checked)
  Config file path:    C:\Users\<you>\.codex\config.toml

  IMPORTANT: SindByte must be running before you start Codex.

--------------------------------------------------------------------------------
 3. INSTALL CODEX CLI
--------------------------------------------------------------------------------
  STEP 1 -- Open PowerShell and install:

    npm install -g @openai/codex

  STEP 2 -- Verify installation:

    codex --version

  On Windows you can also install the Codex App or use WSL.

--------------------------------------------------------------------------------
 4. CONFIGURE CODEX FOR SINDBYTE
--------------------------------------------------------------------------------
Codex uses a TOML config file. Create or edit it with Notepad:

  STEP 1 -- Open the config folder:

    mkdir "%USERPROFILE%\.codex" 2>$null
    notepad "%USERPROFILE%\.codex\config.toml"

  STEP 2 -- Paste this config inside:

    model = "LMDirect"
    model_provider = "sindbyte"

    [model_providers.sindbyte]
    name = "SindByte MCP Server"
    base_url = "http://127.0.0.1:8091/v1"
    wire_api = "chat"
    env_key = "SINDBYTE_API_KEY"
    requires_openai_auth = false

  STEP 3 -- Save and close Notepad.

  STEP 4 -- Set the API key in your terminal:

    set SINDBYTE_API_KEY=sk-sindbyte-local

    To make this permanent, add it to Windows environment variables
    (Win+R -> sysdm.cpl -> Advanced -> Environment Variables).

  STEP 5 -- Start Codex in your project folder:

    cd "[your-project-path]"
    codex

--------------------------------------------------------------------------------
 5. ALTERNATIVE: ENV-VAR ONLY SETUP (no config file)
--------------------------------------------------------------------------------
If you prefer not to edit config.toml, you can use the built-in
openai provider and override the base URL:

  STEP 1 -- Set environment variables:

    set OPENAI_BASE_URL=http://127.0.0.1:8091/v1
    set OPENAI_API_KEY=sk-sindbyte-local

  STEP 2 -- Start Codex:

    codex --model LMDirect

  This is the quickest way to test but gives you less control
  over model selection and IQ profiles.

--------------------------------------------------------------------------------
 6. USING IQ TOOLS WITH CODEX
--------------------------------------------------------------------------------
Codex does not support per-request IQ options like OpenCode does.
To use IQ Tools with Codex, you have two options:

  OPTION A -- Set the default IQ profile in SindByte Config
    1. Open SindByte tray icon -> Config
    2. Find API Provider -> Default IQ Profile
    3. Set it to "default" or "research"
    4. Save and restart SindByte
    5. All Codex requests will now use that IQ pipeline

  OPTION B -- Use model name as IQ selector
    SindByte recognises model names that start with "iq/":

      codex --model iq/full
      codex --model iq/research
      codex --model iq/trading
      codex --model iq/minimal
      codex --model iq/off

    This lets you switch IQ profiles per session.

--------------------------------------------------------------------------------
 7. TROUBLESHOOTING
--------------------------------------------------------------------------------

  PROBLEM: "codex command not found"
  FIX:     Make sure npm global bin is in your PATH.
           Run: npm config get prefix
           Add the "bin" subfolder to your PATH.

  PROBLEM: "Cannot connect" or "Connection refused"
  FIX:     Check SindByte is running. Verify the port in SindByte Config.

  PROBLEM: "Invalid API key" or 401 error
  FIX:     Make sure sk-sindbyte-local starts with "sk-".
           Check that SINDBYTE_API_KEY or OPENAI_API_KEY is set.

  PROBLEM: Codex ignores my custom base_url
  FIX:     Make sure model_provider matches the [model_providers.XXX] name.
           Also check that requires_openai_auth = false is set.

--------------------------------------------------------------------------------
 8. QUICK REFERENCE
--------------------------------------------------------------------------------
  | Setting          | Value                           |
  |------------------|---------------------------------|
  | Tool             | Codex CLI (npm: @openai/codex)  |
  | Base URL         | http://127.0.0.1:8091/v1        |
  | API Key          | sk-sindbyte-local               |
  | Config file      | ~/.codex/config.toml            |
  | Provider name    | sindbyte                        |
  | Model prefix     | openai/ or iq/                  |
  | IQ Timeout       | 3600 sec (1 hour)               |

================================================================================
  END OF GUIDE
================================================================================
