Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/claude-code-adapter-cli/claude-code-adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func newClaudeClaudeAdapterCliCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "claude-code-adapter-cli [COMMAND] [OPTIONS]",
Short: "Claude Code Adapter Command-Line Interface",
Version: "v0.8.1",
Version: "v0.8.2",
SilenceErrors: true,
SilenceUsage: true,
}
Expand Down
16 changes: 11 additions & 5 deletions cmd/claude-code-adapter-cli/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ func newServeCommand() *cobra.Command {
Short: "Start claude-code-adapter-cli http server",
Args: cobra.NoArgs,
PreRun: func(*cobra.Command, []string) {
viper.SetOptions(viper.WithLogger(slog.Default()))
viper.SetConfigName("config")
viper.SetConfigType("yaml")
viper.AddConfigPath("$HOME/.claude-code-adapter/")
viper.AddConfigPath(".")
if configFile != "" {
viper.SetConfigFile(configFile)
}
Expand Down Expand Up @@ -80,11 +85,6 @@ func newServeCommand() *cobra.Command {
cobra.CheckErr(viper.BindPFlag(delimiter.ViperKey("http", "port"), flags.Lookup("port")))
cobra.CheckErr(viper.BindPFlag(delimiter.ViperKey("http", "host"), flags.Lookup("host")))
cobra.CheckErr(viper.BindPFlag(delimiter.ViperKey("snapshot"), flags.Lookup("snapshot")))
viper.SetOptions(viper.WithLogger(slog.Default()))
viper.SetConfigName("config")
viper.SetConfigType("yaml")
viper.AddConfigPath("$HOME/.claude-code-adapter/")
viper.AddConfigPath(".")
return cmd
}

Expand Down Expand Up @@ -394,6 +394,12 @@ func onMessages(cmd *cobra.Command, prov provider.Provider, rec snapshot.Recorde
if err != nil {
panic(fmt.Errorf("unreachable: %s", err.Error()))
}
if targetModel, ok := prof.Options.GetModels()[req.Model]; ok {
rawBody, err = sjson.SetBytes(rawBody, "model", targetModel)
if err != nil {
panic(fmt.Errorf("unreachable: %s", err.Error()))
}
}
options = append(options, provider.ReplaceBody(rawBody))
}
stream, header, err = prov.GenerateAnthropicMessage(ctx, req, options...)
Expand Down
6 changes: 2 additions & 4 deletions pkg/adapter/convert_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ func ConvertAnthropicRequestToOpenRouterRequest(
TopP: src.TopP,
Usage: &openrouter.ChatCompletionUsageOptions{Include: true},
}
if modelMapper := prof.Options.GetModels(); modelMapper != nil {
if targetModel, ok := modelMapper[dst.Model]; ok {
dst.Model = targetModel
}
if targetModel, ok := prof.Options.GetModels()[dst.Model]; ok {
dst.Model = targetModel
}
if metadata := src.Metadata; metadata != nil && metadata.UserID != "" {
dst.User = metadata.UserID
Expand Down