continuedev/continue · error · Error

Model ${modelName} does not have an apiKeyLocation or envSec

Error message

Model ${modelName} does not have an apiKeyLocation or envSecretLocations defined

What it means

createOpenAIClient requires each matched model config to declare where its API key lives; if the model entry has neither apiKeyLocation nor envSecretLocations, it can't build the ContinueProperties and throws.

Source

Thrown at packages/continue-sdk/typescript/src/createOpenAIClient.ts:78

          const modelName = body.model;

          // Look up the model in the assistant's models
          const modelConfig = assistantModels?.find(
            (m) => m?.model === modelName || m?.model.endsWith(modelName),
          );

          if (!modelConfig) {
            throw new Error(
              `Model ${modelName} not found in assistant configuration`,
            );
          }

          if (
            !("apiKeyLocation" in modelConfig) &&
            !("envSecretLocations" in modelConfig)
          ) {
            throw new Error(
              `Model ${modelName} does not have an apiKeyLocation or envSecretLocations defined`,
            );
          }

          const continueProperties: ContinueProperties = {
            apiKeyLocation: modelConfig.apiKeyLocation,
            envSecretLocations: modelConfig.envSecretLocations,
            orgScopeId: organizationId ?? null,
          };

          // Update the request with the modified body
          modifiedInit.body = JSON.stringify({
            ...body,
            continueProperties,
          });
        } catch (e) {
          // If parsing fails, proceed with the original body
        }

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Add apiKeyLocation (e.g. {type:'api'}) or envSecretLocations (e.g. ['MY_API_KEY']) to the model config
  2. Update the assistant config from its source so key metadata is included
  3. Upgrade/downgrade continue-sdk to the version matching the config schema
  4. For BYO-key setups, route the request through a model config that declares its key location

Example fix

// before
models: [{ model: 'gpt-4o', provider: 'openai' }]

// after
models: [{ model: 'gpt-4o', provider: 'openai', apiKeyLocation: { type: 'api' } }]
Defensive patterns

Strategy: type-guard

Validate before calling

const ok = models.every(m => 'apiKeyLocation' in m || 'envSecretLocations' in m);

Type guard

function hasKeyLocation(m: any): m is { apiKeyLocation?: unknown; envSecretLocations?: unknown } { return 'apiKeyLocation' in m || 'envSecretLocations' in m; }

Try / catch

try { await client.chat.completions.create(req); } catch (e) { if (/apiKeyLocation/.test(e.message)) throw new Error('Model config missing secret location — update assistant config'); throw e; }

Prevention

When it happens

Trigger: A model in the assistant config matches the request but its config object lacks both 'apiKeyLocation' and 'envSecretLocations' keys.

Common situations: Custom/hand-built model configs, schema drift after upgrading continue-sdk where secret location fields were renamed, or assistant configs from a hub version that omits key metadata.

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/66c28599a7d0e76c. Report an issue: GitHub.