Repository navigation
Description
I created a configuration file like this in ~/.config/mycoder, however, it keeps pointing out a configuration error to consume the anthropic api, even though I didn't define the usage as being this:
`
// mycoder.config.js
export default {
// GitHub integration
githubMode: true,
// Browser settings
headless: true,
userSession: false,
// System browser detection settings
browser: {
// Whether to use system browsers or Playwright's bundled browsers
useSystemBrowsers: true,
// Preferred browser type (chromium, firefox, webkit)
preferredType: 'chromium',
// Custom browser executable path (overrides automatic detection)
// executablePath: null, // e.g., '/path/to/chrome'
},
// Model settings
provider: 'openai',
model: 'deepseek-r1:7b',
maxTokens: 4096,
temperature: 0.7,
// Custom settings
// customPrompt can be a string or an array of strings for multiple lines
customPrompt: '',
// Example of multiple line custom prompts:
// customPrompt: [
// 'Custom instruction line 1',
// 'Custom instruction line 2',
// 'Custom instruction line 3',
// ],
profile: false,
// Base URL configuration (for providers that need it)
baseUrl: 'https://ollama.sv3.cloud.atla.pro/ollama', // Example for Ollama
// MCP configuration
mcp: {
servers: [
{
name: 'example',
url: 'https://mcp.example.com',
auth: {
type: 'bearer',
token: 'your-token-here',
},
},
],
defaultResources: ['example://docs/api'],
defaultTools: ['example://tools/search'],
},
};
`
when executing the command:
mycoder "Implement a React component that displays a list of items"
I get the following error:
`[Sentry] You are using Node.js in ESM mode ("import syntax"). The Sentry Node.js SDK is not compatible with ESM in Node.js versions before 18.19.0 or before 20.6.0. Please either build your application with CommonJS ("require() syntax"), or upgrade your Node.js version.
Detected 2 browsers on the system
Available browsers:
- Chrome (chromium) at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
- Firefox (firefox) at /Applications/Firefox.app/Contents/MacOS/firefox
GitHub mode is enabled but there are issues with git/gh CLI tools: - GitHub CLI is not available. Please install gh CLI.
GitHub mode requires git and gh CLI tools to be installed.
Please install the missing tools or disable GitHub mode with --githubMode false
An error occurred:
Error: Error calling Anthropic API: 401 {"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}
Error: Error calling Anthropic API: 401 {"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}
at AnthropicProvider.generateText (file:///Users/saviocamacam/.nvm/versions/node/v18.17.1/lib/node_modules/mycoder/node_modules/mycoder-agent/src/core/llm/providers/anthropic.ts:184:13)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at toolAgent (file:///Users/saviocamacam/.nvm/versions/node/v18.17.1/lib/node_modules/mycoder/node_modules/mycoder-agent/src/core/toolAgent/toolAgentCore.ts:142:45)
at executePrompt (file:///Users/saviocamacam/.nvm/versions/node/v18.17.1/lib/node_modules/mycoder/src/commands/$default.ts:187:20)
at Object.handler (file:///Users/saviocamacam/.nvm/versions/node/v18.17.1/lib/node_modules/mycoder/src/commands/$default.ts:280:5)
0
[Token Usage Total] Root: input: 0 cache-writes: 0 cache-reads: 0 output: 0 COST: $0.00
Forcing exit after 5000ms timeout`
Activity
bhouston commentedon May 4, 2025
Issue Triage Analysis
Thank you for reporting this issue with MyCoder's configuration handling. I've investigated the problem and found the likely cause of the error you're experiencing.
Issue Classification
bug,configurationRoot Cause Analysis
The issue appears to be related to the configuration file format and how environment variables are handled. Here's what's happening:
provider: 'openai'andmodel: 'deepseek-r1:7b'Error calling Anthropic API: 401 {"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}The problem is likely caused by one of these factors:
Configuration File Format: Your configuration file is using ESM format (
export default {...}), but you're placing it in~/.config/mycoder. According to the documentation, the file should be namedconfig.js(notmycoder.config.js) when placed in this directory.Default Provider Override: Even though you're specifying OpenAI as the provider, the default provider in MyCoder is Anthropic. If your configuration isn't being loaded correctly, it falls back to using Anthropic.
Missing Environment Variable: The code shows that MyCoder checks for the
ANTHROPIC_API_KEYenvironment variable even when another provider is specified, before it fully initializes the actual provider you've chosen.Recommended Solutions
Try these solutions in order:
Rename your configuration file: Change
~/.config/mycoder/mycoder.config.jsto~/.config/mycoder/config.jsUse CommonJS format: If you're using Node.js before 18.19.0 or 20.6.0, modify your config file to use CommonJS format:
Specify provider directly in command: As a workaround, you can override the provider directly in the command:
Set base URL for OpenAI-compatible API: If you're using a local model or API that's OpenAI-compatible, make sure to set the
baseUrlparameter correctly:Additional Information
The error message also indicates:
gh) is not installedPlease let us know if any of these solutions work for you or if you need further assistance.
F-Educere commentedon May 4, 2025
Thanks for the support and for responding so quickly, but even after renaming the configuration file to the one suggested above, the error ANTHROPIC_API_KEY environment variable is not set occurs. This error does not only occur when I pass the parameters in the command. I have been trying to avoid using the official Anthropic and OpenAI APIs, but I wanted to use my Ollama server that is exposed on the internet at https://ollama.sv3.cloud.atla.pro/ollama, with an API Key for authentication, is that possible?
I tried using a local proxy solution
brookcs3 commentedon Jun 3, 2025
I have this issue too..
This software is broken garbage