Show the key in one-api Channel Settings
This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文

This is hidden by default, but if you're using it only yourself, or want to make management easier, you can display it here.
Where to Make the Change
In the source file model/channel.go
Original code
func GetChannelById(id int, selectAll bool) (*Channel, error) {
channel := Channel{Id: id}
var err error = nil;
if selectAll {
err = DB.First(&channel, "id = ?", id).Error
} else {
err = DB.Omit("key").First(&channel, "id = ?", id).Error
}
return &channel, err
}
Replace with
func GetChannelById(id int, selectAll bool) (*Channel, error) {
channel := Channel{Id: id}
var err error = nil
err = DB.First(&channel, "id = ?", id).Error
return &channel, err
}
Rebuild to Apply the Change
Last updated 2025-06-25
Comments 0