← All documentation

Setup CLI with AskCodi API

Step-by-step guide to configure Continue.dev CLI with AskCodi API. Learn YAML configuration, environment variables, and OpenAI-compatible API setup for terminal-based AI coding.

Install Continue.dev CLI

Continue.dev provides a command-line interface for terminal-based AI assistance. Install it using npm:

npm install -g @continue-dev/cli

This command installs the continue executable globally. Verify the installation by running continue --version. The command should output the installed version number.

Make sure Node.js 18 or higher is installed on your system. The CLI requires a modern JavaScript runtime for proper execution. You can check your Node.js version with node --version.

Set Up Configuration File

The CLI uses the same configuration system as the IDE extension. Create a directory for your Continue configuration:

mkdir -p ~/.continue

Create a configuration file at ~/.continue/continue_config.yaml. This file tells the CLI which AI models to use and how to connect to them.

Create CLI Configuration with AskCodi

Add the following configuration to your continue_config.yaml file:

models:
  - name: "askcodi-model"  # Replace with actual model name from AskCodi
    provider: "openai"
    model: "askcodi-model"  # Replace with actual model name from AskCodi
    apiBase: https://api.askcodi.com/v1
    apiKey: ${ASKCODI_API_KEY}

# Configure default model for CLI
defaultModel: "askcodi-model"

The baseURL must point to AskCodi's OpenAI-compatible endpoint. The provider is "openai" because AskCodi implements the OpenAI API specification. This allows seamless integration with Continue.dev.

Configure Environment Variables

Set your AskCodi API key in an environment variable. Add this line to your shell configuration file (.bashrc, .zshrc, etc.):

export ASKCODI_API_KEY="your-actual-api-key-from-askcodi-here"

Load the new environment variable:

source ~/.zshrc  # or ~/.bashrc depending on your shell

Verify the environment variable is set:

echo $ASKCODI_API_KEY

This should output your API key. If it's empty, double-check the variable name and make sure you sourced the correct shell configuration file.

Test Basic CLI Functionality

Run the Continue CLI to start an interactive session:

continue

This command opens a chat interface connected to your AskCodi configuration. You can send messages to the AI and receive responses directly in your terminal.

Exit the interactive session by typing /exit or pressing Ctrl+C to interrupt the process.

Use CLI for Code Analysis

Navigate to a project directory in your terminal. Use the continue command to analyze files:

continue ask "Explain this code" < path/to/your/file.js

This sends the content of file.js to AskCodi and asks for an explanation. The response appears directly in your terminal.

For longer code analysis, use the interactive mode:

continue
# Now you can refer to files in the current directory
/ask What does this function do? path/to/function.js

Configure Model-Specific Settings

You might want different settings for different tasks. Create multiple model configurations in your YAML file:

models:
  - name: "gpt-4o-mini"
    provider: "openai"
    model: "gpt-4o-mini"
    apiBase: https://api.askcodi.com/v1
    apiKey: ${ASKCODI_API_KEY}
  - name: "gpt-4o"
    provider: "openai"
    model: "gpt-4o"
    apiBase: https://api.askcodi.com/v1
    apiKey: ${ASKCODI_API_KEY}

# Use first model by default for CLI
defaultModel: "gpt-4o-mini"

Switch between models using the model selection in interactive mode. The CLI remembers your current model until you change it.

Use Continue with Git and Code Review

The CLI works well with common development tools. Get a code review of your current Git changes:

git diff HEAD~1 | continue ask "Review these changes"

This pipes the diff to Continue's AskCodi model for analysis. The AI will review the changes and suggest improvements or flag potential issues.

For pull request summaries:

git diff main...current-branch | continue ask "Summarize these changes for a pull request"

Integrate with Your Development Workflow

Create shell aliases for common Continue.dev tasks. Add these to your shell configuration file:

# Quick code explanation
alias explain='continue ask "Explain the following code:"'

# Code review of current Git diff
alias review='git diff HEAD | continue ask "Review these changes:"'

# Generate documentation
alias docs='continue ask "Generate documentation for:"'

Reload your shell configuration and use these shortcuts for common tasks:

explain < path/to/complex/function.js

Monitor Token Usage

Track your AskCodi API usage through the AskCodi dashboard. The CLI makes the same API calls as the extension, so usage applies to your total API quota.

Consider using different models for different tasks to optimize costs. Use faster, cheaper models for autocomplete and basic chat. Reserve more advanced models for complex analysis and editing tasks.

Troubleshooting CLI Issues

Command not found: If continue command returns "command not found", verify npm installation and check if the global npm modules are in your PATH. Find the npm global bin directory with npm config get prefix and ensure it's in your PATH.

API Connection Errors: Verify that apiBase in your configuration matches https://api.askcodi.com/v1. Check that your ASKCODI_API_KEY environment variable is correctly set and accessible in your current shell session.

Model Not Connecting: Ensure the model name in your configuration matches a valid model available through AskCodi. Contact AskCodi support if you're unsure about available model names.

Advanced CLI Usage

Use Continue.dev CLI for batch processing tasks:

# Process multiple files
find . -name "*.js" -exec continue ask "Summarize this file:" {} \;

Integrate with other command-line tools:

# Review recent changes and save output
git log --oneline -10 | continue ask "Analyze recent changes" > review.txt

Quick Takeaways

  • Install CLI with npm install -g @continue-dev/cli
  • Configure the same YAML file used by IDE extension but for terminal use
  • Use environment variables to store API keys securely
  • Test with basic continue command to start interactive session
  • Use with Git commands for code reviews and analysis
  • Create shell aliases for common Continue.dev tasks
  • Monitor API usage through AskCodi dashboard
  • Integrate with other command-line tools for advanced workflows

Conclusion

Configuring Continue.dev CLI with AskCodi API brings AI coding assistance to your terminal workflows. The same powerful models used in your IDE are available in the command line, providing consistency across your development environment.

Your CLI setup enables code analysis, reviews, and explanations without leaving the terminal. The configuration uses the same system as the IDE extension, making it easy to maintain consistent settings.

The next step: experiment with the CLI in your actual development projects. Integrate it into your Git workflow and create aliases for tasks you perform frequently.

Something missing or wrong in this guide? Talk to us