Skip to content

P1: fetchMLXModels() doesn't pass API key to MLX /v1/models — returns empty on auth-enabled MLX #46

Closed

Description

@dahai80

Bug Description

FusionCodeBridge.fetchMLXModels() makes a plain GET request to http://localhost:11434/v1/models without passing any Authorization header. When MLX has API key auth enabled (the default setup), this request returns 401 and the function returns an empty array.

Impact

  • Model list fallback to MLX always fails when auth is configured
  • Users see no models when fusion-code is offline

Evidence

private func fetchMLXModels() async -> [String] {
    guard let url = URL(string: "http://localhost:11434/v1/models") else { return [] }
    do {
        let (data, _) = try await URLSession.shared.data(from: url)  // No auth!

Suggested Fix

Add Authorization header using FusionConfig.shared.mlxResolvedApiKey:

var request = URLRequest(url: url)
let key = FusionConfig.shared.mlxResolvedApiKey
if !key.isEmpty { request.setValue("Bearer \(key)", forHTTPHeaderField: "Authorization") }
let (data, _) = try await URLSession.shared.data(for: request)

🤖 Generated with Claude Code

Activity

  1. dahai80 commented on Aug 3, 2026

    @dahai80
    OwnerAuthor

    Cross-filed to fusion-studio: dahai80/fusion-studio#106 — this is a Swift bug in FusionCodeBridge, not fixable from fusion-code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions