← Back to Support Overview

NETVARA KNOWLEDGE BASE

How to Use Netvara Client with OpenAI Codex

How to Use Netvara Client with OpenAI Codex

Overview

OpenAI Codex CLI can use Netvara Client as an OpenAI-compatible backend. Set the local base URL and authentication token, choose an advertised model, and run Codex from your project repository.

The local endpoint is:

http://127.0.0.1:8091/v1

Prerequisites

  • Netvara Client is installed and running.
  • OpenAI Codex CLI is installed and available as the codex command.
  • You have a project repository ready for testing.
  • At least one model is advertised by Netvara Client.

Step-by-Step Instructions

1. Find an advertised model

List the models available through the local gateway:

curl -sS \
  -H "Authorization: Bearer $(cat ~/.netvara-client/local_api_key)" \
  http://127.0.0.1:8091/v1/models

Copy the model ID you want Codex to use.

2. Configure the Codex environment

Set these variables in the terminal session used to launch Codex:

export OPENAI_BASE_URL=http://127.0.0.1:8091/v1
export OPENAI_API_KEY="$(cat ~/.netvara-client/local_api_key)"

Treat the token as a secret. Do not commit it to the repository or place it in a file tracked by Git.

3. Select the local model

Use the model-selection setting supported by your Codex CLI version. For example:

codex --model your-local-model

If the option differs in your version, run codex --help and use the documented model option or local configuration file.

4. Run Codex in a project repository

From the repository root, run a small, reviewable task:

cd /path/to/your/project
codex exec --model your-local-model "Explain the project structure without changing files."

Once the connection is verified, you can run your normal Codex workflows. Review proposed changes before applying them.

Verification

1. Confirm the local model is listed:

   curl -sS -H "Authorization: Bearer $OPENAI_API_KEY" \
     "$OPENAI_BASE_URL/models"

2. Run a one-step Codex request from the project repository:

   codex exec --model your-local-model "Reply with: Codex is using Netvara."

3. Confirm Codex returns a response and does not report a connection, authentication, or model-not-found error.
4. Verify the selected model matches one of the IDs returned by /v1/models.

Troubleshooting & Common Questions

Codex cannot connect

Check that Netvara Client is running and that OPENAI_BASE_URL is set to http://127.0.0.1:8091/v1. Query /models directly to isolate connectivity issues.

Codex reports an invalid API key

Reload the token in the same shell that launches Codex:

export OPENAI_API_KEY="$(cat ~/.netvara-client/local_api_key)"

If the token file is missing or empty, repair the Netvara Client installation before retrying.

The selected model is not found

Use the exact model ID returned by /v1/models. If the model is not listed, update model visibility in Netvara Client and restart the client.

What does `codex exec` do?

codex exec runs a task in non-interactive mode, which makes it useful for a first connectivity check and for scripted workflows. Start with a read-only request before allowing file edits.

How do I return to the previous Codex provider?

Unset the variables in the current shell, then launch Codex again:

unset OPENAI_BASE_URL OPENAI_API_KEY

← Back to Support Overview