Amp Server更新了

如果不知道是啥,请看 https://linux.do/t/topic/839005?u=youglin

许多小伙伴可能不知道,我两个星期前就做了一次比较完善的更新,修复了compact报错的问题,修复了无法使用google系列endpoint接入问题。现在整个体验是非常流畅的了,感兴趣的可以看这次commit:Add Google API proxy support and improve proxy service · YougLin-dev/amp-server@24224b6 · GitHub

提供一个参考配置文件。
你可以为每个端点都指定不同的上游中转,可以通过 custom_headers 提供 自定义的authorization 分开各自鉴权。

.env配置文件

HOST=127.0.0.1
PORT=8888

MAX_REQUEST_BODY_BYTES=104857600

# 写大点就行了
CONNECT_TIMEOUT_SECS=500
REQUEST_TIMEOUT_SECS=60000

# 健全,google的可以单独定义在这里,也可以像我下面提到的,直接用custom header去实现。
AMP_API_KEY=test-api-key-please-change-me
GOOGLE_API_KEY=test-api-key-please-change-me

# 日志,喜欢多点就debug,少点就info
RUST_LOG=debug

proxy_config.yaml配置文件

endpoints:
  - path: "/api/provider/openai/v1/responses"
    target_url: "https://你的某个支持response接口的中专/v1/responses"
    method: "POST"
    response_type: "stream"
    custom_headers: {}
    forward_request_headers:
      - "authorization"
      - "content-type" 
      - "user-agent"
      - "accept"
      - "accept-encoding"
    forward_response_headers:
      - "content-type"
      - "cache-control"
    enabled: true

  - path: "/api/provider/anthropic/v1/messages"
    target_url: "https://你的某个支持v1/messages接口的中专/v1/messages"
    method: "POST"
    response_type: "stream"
    custom_headers: {}
    forward_request_headers:
      - "authorization"
      - "content-type"
      - "user-agent" 
      - "accept"
      - "accept-encoding"
      - "anthropic-version"
      - "x-api-key"
    forward_response_headers:
      - "content-type"
      - "cache-control"
    enabled: true

  - path: "/api/tab/llm-proxy"
    target_url: "https://ampcode.com/api/tab/llm-proxy"
    method: "POST"
    response_type: "sse"
    custom_headers: {}
    forward_request_headers:
      - "authorization"
      - "user-agent"
      - "x-amp-feature"
      - "accept-language"
      - "sec-fetch-mode"
    forward_response_headers:
      - "alt-svc"
      - "content-security-policy"
      - "fireworks-backend-host"
      - "fireworks-cached-prompt-tokens"
      - "fireworks-deployment"
      - "fireworks-generation-queue-duration"
      - "fireworks-num-concurrent-requests"
      - "fireworks-prefill-duration"
      - "fireworks-prefill-queue-duration"
      - "fireworks-prompt-tokens"
      - "fireworks-sampling-options"
      - "fireworks-server-time-to-first-token"
      - "fireworks-speculation-matched-tokens"
      - "fireworks-speculation-prompt-tokens"
      - "fireworks-tokenizer-duration"
      - "fireworks-tokenizer-queue-duration"
    enabled: true

  # Google Generative Language (gemini) 
  # Matches: /api/provider/google/v1beta1/publishers/google/models/<model>:generateContent
  # For example: /api/provider/google/v1beta1/publishers/google/models/gemini-2.5-flash-lite-preview-09-2025:generateContent
  # Captures the remainder after /models/ as "rest"; the server derives {model} = rest.split(":").next()
  - path: "/api/provider/google/v1beta1/publishers/google/models/{*rest}"
    target_url: "https://某支持google格式的接口/v1/v1beta/models/gemini-2.5-pro:generateContent"
    method: "POST"
    response_type: "stream"
    custom_headers: {}
    forward_request_headers:
      - "content-type"
      - "user-agent"
      - "accept"
      - "accept-encoding"
    forward_response_headers:
      - "content-type"
      - "cache-control"
    enabled: true

如果有任何使用上的问题,大家可以在下面互相探讨,配置其实很简单。

放几个主要平台的可执行文件,晚点我写个action去自动发版吧,虽然本来比较懒没做 :innocent:

window64:https://c.wss.cc/f/ia0grsp3qjp

32 个赞

抢个沙发。

有意思,抽时间部署个试试看

1 个赞

马上star

太强了,大佬

感谢大佬分享

看了 github 也没搞懂这个是干嘛的

https://linux.do/t/topic/839005?u=youglin

1 个赞

立刻部署

还是不会用,如何在 openai 和 anthropic 两个切换?如何自定义 key 和 模型?
能不能给个案例,比如如何接入魔搭的 glm-4.6

官方不是免费了吗

有使用其他模型的需求啊,我加一个吧,之前没这个需求

感谢分享,已Star :hand_with_index_finger_and_thumb_crossed:

Ampcode 是个被低估的工具,之前注册送10美元,Twitter 上官方搞活动送了 20 刀,我自己用下来效果非常好。但没啥羊毛薅,所以用的人不多。 这个公司之前的 cody 搞了两年,有一定的技术积累。目前的它家的 tab 补全是 vscode 上能免费用到的最好补全工具。 现在首创看广告免费用的商业模式,但模型不知道用什么,反正非常快,解决复杂问题的能力一般。

楼主这个工具希望能进一步优化,可以对接其他模型,让大家都能感受到 ampcode 的能力。

佬,amp补全和supermaven补全哪个好用?