Model advanced configuration and debugging
This page covers advanced model settings, connection troubleshooting, logs, and tracing.
Verify model connectivity
Check whether your configured models can connect and work with Midscene:
The command uses your environment variables and optionally loads .env from the current directory. Values in .env override matching environment variables.
Example success output (excerpt)
Example failure output (excerpt)
If verification fails with a connection error, you can test the model service directly to help isolate the problem.
Optional: test the model API with curl
The following curl request checks whether the Base URL, API key, and model name work. It only verifies basic model API connectivity. It does not check whether the model meets Midscene's compatibility requirements.
If the curl request succeeds but the Midscene verification command fails, the model API is reachable. Continue by checking the model capabilities and Midscene configuration.
Model configuration by intent
One Default model is sufficient for most tasks. When a task needs stronger planning, more precise localization, or better page understanding, configure a dedicated model for that intent to use a model better suited to that capability.
You can configure separate models for Planning, Locate, and Insight intents. These settings use the same parameter suffixes and meanings as the Default model settings below. Replace the prefix for each role:
Provide a complete configuration for each dedicated model, including its endpoint, API key (if required by the connection method), model name, and family, along with any optional settings you need.
A role without a dedicated model uses the Default model.
View multi-model configuration example
Keep the Default model and add dedicated models as needed. Replace the placeholders and model names with the actual configuration from your providers.
Advanced settings (optional)
Configuration reference
To configure a separate model for Planning, Locate, or Insight, use the corresponding environment variable prefix. See Model configuration by intent.
Use the Responses API
Midscene uses Chat Completions (openai-chat) by default. Among the built-in model adapters, only gpt-5 and gpt-6 currently support the Responses API. Setting openai-responses for another model family causes an unsupported-protocol error.
For the official OpenAI endpoint, add the following to your GPT model configuration:
Set the model name, API key, and family as shown in the GPT configuration example. Do not append /responses to the Base URL; the SDK adds it automatically.
The Responses API is not restricted to the official OpenAI endpoint. Azure OpenAI and other compatible endpoints can also be used, but both the endpoint and the selected GPT model must support this protocol. Chat Completions compatibility alone does not imply Responses compatibility. See the Azure OpenAI FAQ for configuration and the verified coordinate-offset scenario.
For a dedicated GPT model, use MIDSCENE_PLANNING_MODEL_PROTOCOL, MIDSCENE_LOCATE_MODEL_PROTOCOL, or MIDSCENE_INSIGHT_MODEL_PROTOCOL for the corresponding role. Each model's protocol is configured independently and does not affect the others.
Model-native thinking
Midscene disables model-native thinking by default for better execution speed and stability. If a model cannot disable native thinking, Midscene reduces it as much as possible by controlling the thinking granularity or budget.
The following environment variables provide a unified Midscene abstraction over provider-specific parameters. The parameters sent to the model depend on MIDSCENE_MODEL_FAMILY.
MIDSCENE_MODEL_REASONING_ENABLED explicitly controls whether model-native thinking is enabled:
false: Force-disable model-native thinking. This is the Midscene default.true: Force-enable model-native thinking.default: Follow the model's default behavior. Midscene does not send a parameter that enables or disables thinking, and it ignores explicitMIDSCENE_MODEL_REASONING_BUDGETandMIDSCENE_MODEL_REASONING_EFFORTsettings.
Model-specific support and parameter mappings
The following model families currently support MIDSCENE_MODEL_REASONING_ENABLED:
- Qwen: Maps to
enable_thinking. - Doubao: Maps to
thinking.type. - DeepSeek: Maps to
thinking.type. - Zhipu GLM: Maps to
thinking.type. - GPT-5: Maps to
reasoning_effort. Midscene usesmediumwhen enabled andnonewhen disabled. - Gemini: Maps to
thinking_config.thinking_level. Midscene usesmediumwhen enabled andminimalwhen disabled. - Kimi K2 series: Maps to
thinking.type. - Xiaomi MiMo: Maps to
thinking.type.
MIDSCENE_MODEL_REASONING_BUDGET controls the thinking budget. Qwen currently supports this setting through thinking_budget.
MIDSCENE_MODEL_REASONING_EFFORT controls thinking effort. The following model families currently support it:
- Doubao: Maps to
reasoning_effort. - DeepSeek: Maps to
reasoning_effort. - Gemini: Maps to
thinking_config.thinking_level. - GPT-5: Maps to
reasoning_effort. - Kimi K3 series: Maps to
reasoning_effort.
Provider support and accepted values vary. See each provider's official documentation for supported model versions and values. If the current model does not support an explicit setting, Midscene ignores it instead of guessing a provider-specific private parameter.
Troubleshooting
Common configuration errors
MIDSCENE_MODEL_FAMILY is not set to a multimodal model
If you see MIDSCENE_MODEL_FAMILY is not set to a multimodal model with UI localization, make sure the MIDSCENE_MODEL_FAMILY environment variable for the multimodal model is set correctly.
Starting with version 1.0, Midscene recommends using MIDSCENE_MODEL_FAMILY to specify the multimodal model type. Legacy MIDSCENE_USE_... settings remain compatible but are deprecated.
See Use a model API key for the correct model family and a complete configuration example.
Base URL or model name is incorrect
Confirm that MIDSCENE_MODEL_BASE_URL points to the provider's API endpoint. It commonly ends with a version such as /v1. Do not append /chat/completions or /responses; the underlying SDK adds the request path based on the selected API type.
Also confirm that MIDSCENE_MODEL_NAME matches a model available from that endpoint.
When model results are unreliable
If the model connects successfully but produces incorrect actions, misses targets, or misinterprets the page:
- Check the replay report to identify where the task went wrong.
- Try a newer supported model version or compare models on representative tasks.
- If failures concentrate in planning, localization, or page understanding, consider a dedicated model for that intent.
See the Model Selection Guide for model choices and role descriptions.
Debugging capabilities
Debug logs
Set DEBUG when you need additional diagnostic output. Common selectors include:
DEBUG=midscene:ai:profile:statsprints model latency and Token usage.DEBUG=midscene:ai:callprints AI response details.DEBUG=midscene:*prints all Midscene Debug logs.
For the complete selector list, log location, and handling notes, see Runtime configuration: Debug logs.
Usage statistics are also available in generated report files.
Record model calls
Set MIDSCENE_RECORD_MODEL_CALL=true to write model requests, responses, and streaming chunks to a JSONL file:
Each process creates one file, with one JSON event per line. Local recording is available only in Node.js and Electron. Browsers and Workers do not write local files. Codex App Server records also include available protocol metadata.
Every event has a type of request, chunk, response, or error. It also includes an executionId that groups calls and retries under the same execution ID. For HTTP model requests, this value is also sent in the x-midscene-execution-id header. Calls outside a report execution, such as connectivity checks, use a generated ID prefixed with unscoped-.
Model-call records contain request bodies (including custom extraBody), response headers and bodies, streaming responses, and possibly base64-encoded screenshots. Request headers are not recorded.
- Enable recording only while troubleshooting. Files may be large; protect or delete them afterward. The record format is not stable across versions.
- Do not commit
.envfiles, traces, debug logs, or model-call records to source control. - Review logs, traces, and model-call records before sharing them because they can contain model inputs, outputs, or screenshots.
Request tracing headers
Midscene automatically adds the following headers to OpenAI-compatible HTTP model requests:
Calls outside a report execution, such as connectivity checks, use a generated execution ID prefixed with unscoped-. These two headers are sent by default; if headers with the same names are customized in MIDSCENE_*_INIT_CONFIG_JSON, Midscene overrides them.
Observability platforms
The automatic integrations below wrap the OpenAI SDK client used for OpenAI-compatible HTTP requests. They do not apply to Codex App Server or Jev's System One protocol.
Notes:
- LangSmith and Langfuse can be enabled simultaneously.
- This integration supports Node.js only. Browser environments throw an error.
createOpenAIClientreceives the original OpenAI client. If the callback returns a client, that client replaces the automatically wrapped client; apply any tracing wrappers you need inside the callback. If it returns no client, the automatic integrations remain in effect.
LangSmith
LangSmith is a platform for debugging large language models. Midscene provides automatic integration support through a dependency and environment variables.
Install the dependency
Set environment variables
When Midscene creates an OpenAI client for a model request, it logs the enabled wrapper:
For finer-grained control, such as enabling LangSmith only for specific tasks, use createOpenAIClient to wrap the client manually.
Langfuse
Langfuse is an LLM observability platform. Midscene integrates Langfuse's observeOpenAI wrapper to trace OpenAI API calls automatically.
Because Langfuse tracing uses OpenTelemetry, initialize the OpenTelemetry SDK when the application starts.
Install the dependencies
Initialize OpenTelemetry
Add this code at the very top of the application entry file:
Set environment variables
When Midscene creates an OpenAI client for a model request, it logs the enabled wrapper:
This log identifies the wrapper being enabled; it does not confirm that traces reached Langfuse. Run a model request and check your Langfuse project to verify trace delivery.
See the Langfuse OpenAI integration documentation for more configuration options and best practices.
Legacy configuration
These settings remain supported; use the replacements below for new configurations.

