Skip to main content
Qwen Code CLI is an AI-powered coding assistant that supports multiple agent roles directly from your terminal. This guide walks you through connecting SambaNova’s LLMs with Qwen Code CLI to streamline coding, debugging, and architectural tasks in your development workflow.

Prerequisites

Before you begin, ensure you have:
  • A SambaCloud account with an API key, exported as SAMBANOVA_API_KEY:
  • Node.js 22 or later installed on your system

Install Node.js

If you do not have Node.js 22 or later, download an installer from nodejs.org or use a version manager such as nvm. Verify the installation:

Setup

1. Install Qwen Code CLI

Install Qwen Code globally using npm:
Verify the installation:
Launch Qwen Code:
Qwen Code CLI initial launch screen Press Enter to apply the default theme to your user settings. You’ll then be prompted to configure authentication.

2. Configure SambaNova integration

Option A: Interactive configuration SambaNova is not a built-in provider, so choose it through the custom route. Run /auth, select Custom Provider, then supply your SambaNova credentials. Type the key itself rather than the variable name, because these are terminal prompts and do not expand shell variables:
Once you have entered the three values, press Enter to start using the CLI. Option B: Environment variables Alternatively, set these values as environment variables:
Qwen Code reads these variables at startup, so export them before you launch qwen. If you already launched it in the previous step, exit and run qwen again from the same shell, otherwise the running process will not pick up the new values.
All three variables are required together. Qwen Code selects the OpenAI-compatible provider only when the key, the base URL, and a model are all set and non-empty. If any one of them is missing, it selects no provider at all and the resulting error mentions neither the key nor the model, so a single typo looks like an unrelated failure. QWEN_MODEL is accepted in place of OPENAI_MODEL.

Run a single prompt without the interactive UI

Pass -p to run one prompt and exit, which is what you want in a script or a CI job:
--output-format also accepts json and stream-json. Non-interactive runs use the same three environment variables, and they are the only way to authenticate here, since there is no prompt to fall back on. OPENAI_MODEL accepts any model ID from SambaCloud models. Qwen Code is an agentic coder that reads files, edits them, and runs commands through tool calls, so the model you choose has to support function calling. DeepSeek-V3.1 does, and it has a 128k token context window, which is what limits how much of a codebase Qwen can consider at once. On a large repository, scope prompts to specific files with @, as in @app.py, rather than asking about the whole tree.

Example workflow

In this section, you’ll see how Qwen Code CLI can work with a real-world GitHub project. With just a few well-structured prompts, Qwen can help you navigate the codebase, optimize performance, extend functionality, and streamline documentation. Through these examples, you’ll learn how to:
  • Analyze the overall architecture of the codebase
  • Optimize functions for improved memory efficiency
  • Extend functionality by integrating new components
  • Push version-controlled updates directly to GitHub
  • Document all updates in a clear, structured changelog
Let’s walk through each of these steps in detail.

1. Explore and understand a codebase

Clone a sample repository and navigate to the project directory:
Launch Qwen Code CLI:
If you haven’t configured your credentials yet, refer to Setup above, then analyze the project architecture:
Qwen Code CLI showing project architecture summary Qwen CLI automatically scans files such as app.py, config.py, requirements.txt, and generates a high-level architectural summary with suggested next steps.

2. Optimize and test code

After identifying several opportunities for improvement, focus on one of the most impactful changes: optimizing memory usage in the transcribe_audio function. To target that file, use the following prompt:
Qwen Code CLI showing code optimization suggestions Qwen returns a structured set of improvements covering memory efficiency, code simplicity, and maintainability. Beyond pointing out issues, it also suggests concrete code modifications. Qwen applies the following improvements:
  1. Stream transcription results directly instead of collecting all chunks upfront, reducing memory usage and improving responsiveness
  2. Simplify progress tracking by updating the bar to 100% only once transcription is finished
  3. Ensure cleanup of UI elements in error cases so the progress bar and status text are properly cleared

3. Add new features

To expand the application’s capabilities, ask Qwen CLI to add support for YouTube videos:
Qwen analyzes app.py, config.py, and requirements.txt, and identifies that yt-dlp and pydub are already listed as dependencies in the project. Qwen Code CLI adding a YouTube URL input to app.py and listing its remaining tasks Qwen edits app.py to add a YouTube URL field alongside the existing file upload, routes the extracted audio into the transcription pipeline, and tracks the remaining work as a task list. Upon submission, the app extracts the audio and runs it through the existing pipeline.

4. Push changes to GitHub

With the transcribe_audio optimization complete, use Qwen CLI to version and push the updates:
Qwen Code CLI running the git branch, commit, and push commands Qwen automates the entire Git flow by running the git commands for you. In a single prompt, it’s able to:
  1. Create a new branch
  2. Stage and commit the changes
  3. Attempt to push the commit
The push itself only succeeds on a repository you have write access to. Because the sample repository above belongs to someone else, pushing to it returns 403 and a Permission to ... denied message, exactly as shown in the screenshot. The branch and commit are still created locally, so nothing is lost. To complete this step, fork the repository first and clone your fork instead, or run the workflow against a repository of your own.

5. Document updates

Finally, ask Qwen CLI to generate documentation in a professional format:
Qwen Code CLI writing a semantic versioning entry into CHANGELOG.md Qwen uses its WriteFile tool to write the entry into CHANGELOG.md under version v0.2.0, creating the file if the project does not already have one, and following semantic versioning best practices. Once initiated, Qwen also avoids redundant updates, saving tokens and ensuring clean, non-repetitive documentation.

Summary

By connecting SambaNova models with Qwen Code CLI, you streamline your development workflow, saving time on repetitive coding tasks, reducing context switching, and adapting quickly to different project needs through flexible agent roles.

Troubleshooting

You are on Node.js 20 or older. npm neither fails nor warns in this case: it quietly installs the newest release whose engines field allows your Node version, so the install reports success, the CLI starts, and nothing tells you that you are behind. Every release from 0.16.0 onward requires Node.js 22, so a Node.js 20 machine resolves to 0.15.10. Compare the two:
If they differ, check node -v, upgrade to Node.js 22 or later, then reinstall.
OPENAI_API_KEY resolved to an empty string, which happens when SAMBANOVA_API_KEY was never exported in the shell you ran qwen from. Confirm with echo $SAMBANOVA_API_KEY. An export applies only to the shell it ran in, so a new terminal needs it again.
The key reached the API but was not valid. The most common cause is entering the literal text $SAMBANOVA_API_KEY at the API_KEY > prompt, since those prompts do not expand shell variables. Enter the key itself instead.
Model IDs are case-sensitive and take no provider prefix, so DeepSeek-V3.1 works and deepseek-v3.1 returns a 404. Check the current IDs in SambaCloud models and set the one you want as OPENAI_MODEL.
Qwen Code reads OPENAI_API_KEY, OPENAI_BASE_URL, and OPENAI_MODEL when it starts, and a running process does not see variables exported after it launched. Exit qwen, confirm the values with echo $OPENAI_BASE_URL, then start it again from that same shell.
A qwen -p run found an incomplete set of variables. The OpenAI-compatible provider is selected only when the key, the base URL, and a model are all present and non-empty, so an empty OPENAI_API_KEY or a missing OPENAI_MODEL produces this message rather than an authentication error. Print all three and re-run:
Qwen created the branch and the commit successfully, but it cannot push to a repository you lack write access to. This is expected when you cloned someone else’s repository, such as the sample used above. Fork it, point your remote at the fork, and ask Qwen to push again. Nothing needs redoing because the commit already exists locally.
It is not a built-in provider in Qwen Code. You configure it through the OpenAI-compatible settings, which is what the base URL, key, and model values above do. Set those rather than looking for SambaNova by name.

Additional resources

For more information, explore: