Mengonfigurasi Model Gateway
Pelajari cara membuat dan mengelola file konfigurasi Model Gateway, termasuk pengaturan penyedia, definisi model, manajemen kredensial, konfigurasi TLS, dan contoh deployment untuk penyedia model yang didukung.
Model Gateway memungkinkan Bob on-premises terhubung dan merutekan permintaan ke model AI yang didukung di berbagai penyedia, termasuk endpoint yang kompatibel dengan OpenAI, AWS Bedrock, dan Google Vertex AI. Konfigurasi Model Gateway mendefinisikan endpoint model, pengaturan autentikasi, perilaku routing, opsi fallback, dan kapabilitas model, sementara kredensial dan sertifikat sensitif dikelola secara aman melalui config.yaml.
Konfigurasi model gateway adalah file YAML yang menentukan model mana yang dihubungkan oleh gateway dan cara mengautentikasi dengan setiap penyedia.
Konfigurasikan hanya satu model inferensi inti dalam model gateway pada satu waktu. Mengonfigurasi beberapa model inti secara bersamaan tidak didukung dan menghasilkan perilaku yang tidak terdefinisi.
Spesifikasi model
Setiap entri dalam daftar models harus memiliki model_name yang unik. Spesifikasi model lengkap adalah:
- model_name: example_model
# Tipe penyedia (pilih satu per model):
openai_compatible: # — endpoint REST yang kompatibel dengan OpenAI (Azure, …)
bedrock: # — endpoint invoke AWS Bedrock
vertex: # — Google Vertex AI (Gemini)
# Parameter info model (opsional)
model_info:
exposed: true # true: terlihat di daftar /models; false: internal-only
max_input_tokens: 128000 # ukuran context window
max_output_tokens: 4096 # token maksimum yang dapat dihasilkan model
input_cost_per_token: 0.0000025 # biaya dalam USD per token input (digunakan untuk metering penggunaan)
output_cost_per_token: 0.000010 # biaya dalam USD per token output
cache_read_input_token_cost: 0.00 # biaya untuk token input cache-hit (prompt caching)
cache_creation_input_token_cost: 0.00 # biaya untuk menulis entri cache baru
supports_prompt_caching: true # true jika model mendukung prompt caching
supports_function_calling: true # true jika model mendukung tool/function call
supports_tool_choice: true # true jika parameter tool_choice dihormati
supports_reasoning: false # true jika model mendukung parameter reasoning_effort
supports_vision: false # true jika model menerima input gambar dalam chat message
mode: chat # chat | embedding | image_generation
# Daftar berurutan opsional dari nilai model_name untuk dicoba saat model ini tidak tersedia
fallbacks:
- fallback_model
# Parameter permintaan bebas opsional yang ditambahkan ke setiap permintaan yang dikirim ke
# penyedia, termasuk parameter standar (misalnya temperature, top_p,
# max_tokens) dan ekstensi spesifik penyedia (misalnya top_k,
# repetition_penalty, anthropic_beta).
chat_inference_params:
temperature: 0.7
top_p: 0.9Atur supports_vision: true hanya pada model yang menerima input gambar. Jika supports_vision diatur ke true pada model yang tidak mendukung input gambar, mengirim gambar dalam chat akan menghasilkan error dari penyedia. Model berikut tidak mendukung input gambar dan harus menggunakan supports_vision: false atau menghilangkan flag ini: Laguna S2.1 dan Nvidia Nemotron 3.
Penyedia
openai_compatible
Menghubungkan ke model yang di-host secara eksternal dengan REST API yang kompatibel dengan OpenAI (misalnya, Azure OpenAI, endpoint kustom).
openai_compatible:
model: gpt-4o # ID model seperti yang diharapkan oleh penyedia
base_url: https://base_url # Base URL dari deployment model
api_key: env.API_KEY # API key untuk autentikasi. env.<VAR> membaca dari container environment
extra_headers: # Header tambahan untuk disertakan saat inferencing
example_header: env.HEADER_VALUE
insecure_skip_verify: true # Nonaktifkan verifikasi TLS (tidak direkomendasikan untuk produksi)
ca_cert_pem: env.CA_CERT # Sertifikat CA untuk verifikasi TLSbedrock
Menghubungkan ke model yang dilayani melalui AWS Bedrock.
bedrock:
model: claude # ID model seperti yang diharapkan oleh penyedia
region: us-east-1 # AWS region tempat endpoint Bedrock kamu berada
access_key_id: env.AWS_ACCESS_KEY # Bedrock Access Key ID
secret_access_key: env.AWS_SECRET_ACCESS_KEY # Bedrock Secret Access Keyvertex
Menghubungkan ke model yang dilayani melalui Google Vertex AI (Gemini). Kredensial harus disediakan sebagai string JSON service-account yang di-encode base64.
vertex:
model: gemini # ID model seperti yang diharapkan oleh penyedia
project: my-gcp-project # ID project GCP
location: global # Region Vertex AI / "global" untuk Global API
credentials: env.GEMINI_CREDENTIALS # JSON Service-account, di-encode base64YAML anchor
Anchor kredensial
Definisikan kredensial satu kali dan rujuk dengan <<: *anchor-name di beberapa entri model untuk menghindari pengulangan.
# Kredensial AWS Bedrock — dirujuk oleh model bedrock.
x-aws-bedrock-auth: &aws-bedrock-auth
region: us-east-1
access_key_id: env.AWS_ACCESS_KEY
secret_access_key: env.AWS_SECRET_ACCESS_KEY
models:
- model_name: my-bedrock-model
bedrock:
model: claude
<<: *aws-bedrock-auth # gabungkan anchor kredensial yang didefinisikan di atas
model_info:
exposed: true
mode: chatAnchor model
Gabungkan seluruh blok model di beberapa entri untuk menghindari pengulangan konfigurasi penyedia dan model_info.
x-my-base-model: &my-base-model
vertex:
model: gemini-2.5-pro
project: my-gcp-project
location: global
credentials: env.GEMINI_CREDENTIALS
model_info:
exposed: false
supports_reasoning: true
mode: chat
models:
- model_name: my-gemini-model
<<: *my-base-model
- model_name: my-second-gemini-model
<<: *my-base-modelManajemen kredensial dan secret
Secret
Untuk semua secret yang dirujuk dalam konfigurasi model (API key, kata sandi, sertifikat), konfigurasikan di config.yaml instalasi di bawah bob.modelGateway.secrets. Secret dipasang ke dalam container Inference Service saat runtime.
bob:
modelGateway:
secrets:
VAR_BAR_1: FOO_1
VAR_BAR_2: FOO_2
VAR_BAR_N: FOO_NRujuk secret dalam konfigurasi model menggunakan sintaks env.<VAR_NAME>:
api_key: env.VAR_BAR_1Persyaratan TLS dan sertifikat
Root CA bundle menyertakan sertifikat CA publik standar untuk penyedia cloud. Namun, saat menggunakan private endpoint atau server model internal (misalnya, vLLM atau OpenShift AI dengan sertifikat enterprise kustom atau self-signed), kamu harus menyediakan sertifikat Root/Intermediate CA internalmu untuk membangun kepercayaan TLS.
Konfigurasi TLS model-endpoint ini terpisah dari sertifikat yang diperlukan untuk Bob IDE dan Bob Shell untuk terhubung ke backend Bob. Untuk sertifikat endpoint backend dan langkah kepercayaan klien, lihat Sertifikat TLS.
Sertifikat TLS kustom mengikuti pola konfigurasi terdistribusi dua file yang sama seperti kredensial API:
- Di
model-gateway.yaml: Tetapkanca_cert_pemke nama environment variable (misalnya,env.CA_CERT). - Di
config.yaml: Tambahkan nama variabel yang cocok di bawahbob.modelGateway.secretsdan tempel string sertifikat berformat PEM lengkap.
Konfigurasi model gateway:
models:
- model_name: example-model
openai_compatible:
model: mistral-3.5
base_url: https://vllm.internal.corp:8000/v1
api_key: env.MODEL_API_KEY
ca_cert_pem: env.CA_CERT # Merujuk ke nama variabel yang didefinisikan di config.yaml
model_info:
exposed: true
mode: chatKonfigurasi instalasi (config.yaml):
bob:
modelGateway:
secrets:
MODEL_API_KEY: "<your-api-key>"
# Konten sertifikat PEM sebenarnya yang cocok dengan env.CA_CERT di atas:
CA_CERT: |
-----BEGIN CERTIFICATE-----
MIIFazCCA1OgAwIBAgIRAIIQjJaDSmJT3g4qg05...
... [data sertifikat CA lengkap berformat PEM] ...
-----END CERTIFICATE-----Selama deployment, bobctl menyuntikkan CA_CERT ke dalam Kubernetes Secret bob-inference-model-secrets. Ini kemudian dipasang ke dalam layanan inference gateway dan digunakan untuk TLS handshake terhadap server model privatmu.
Contoh lengkap
Berikut adalah contoh lengkap yang mencakup semua tipe penyedia. Simpan konfigurasi model gateway ke sebuah file (misalnya, /tmp/example/model-gateway.yaml) dan rujuk pada saat instalasi.
Konfigurasi model gateway (/tmp/example/model-gateway.yaml)
# ── Anchor kredensial (dibagikan di seluruh entri model melalui YAML merge key) ──────
# Kredensial AWS Bedrock
x-aws-bedrock-auth: &aws-bedrock-auth
region: us-east-1
access_key_id: env.AWS_ACCESS_KEY
secret_access_key: env.AWS_SECRET_ACCESS_KEY
# Kredensial Google Vertex AI
x-vertex-auth: &vertex-auth
project: my-gcp-project
location: global
credentials: env.GEMINI_CREDENTIALS
# ── Anchor model bersama (opsional) ───────────────────────────────────────────
x-my-base-model: &my-base-model
vertex:
model: gemini-2.5-pro
<<: *vertex-auth
model_info:
exposed: true
max_input_tokens: 200000
max_output_tokens: 12000
input_cost_per_token: 0.00000125
output_cost_per_token: 0.00001
cache_read_input_token_cost: 0.000000125
supports_reasoning: true
mode: chat
# ── Model ────────────────────────────────────────────────────────────────────
models:
# Model yang kompatibel dengan OpenAI (misalnya Azure OpenAI) dengan API key
- model_name: my-gpt-model
openai_compatible:
model: gpt-4o
base_url: https://<resource>.cognitiveservices.azure.com/openai
api_key: env.BOB_AZURE_API_KEY
model_info:
exposed: true
max_input_tokens: 128000
max_output_tokens: 4096
input_cost_per_token: 0.0000025
output_cost_per_token: 0.000010
supports_function_calling: true
supports_tool_choice: true
mode: chat
chat_inference_params:
temperature: 0.7
top_p: 0.9
# Model AWS Bedrock
- model_name: my-bedrock-model
bedrock:
model: us.anthropic.claude-3-5-sonnet-20241022-v2:0
<<: *aws-bedrock-auth
fallbacks: # opsional: daftar berurutan dari nama model fallback
- my-fallback-model
model_info:
exposed: false
max_input_tokens: 200000
max_output_tokens: 8192
input_cost_per_token: 0.000003
output_cost_per_token: 0.000015
cache_creation_input_token_cost: 0.00000375
cache_read_input_token_cost: 0.0000003
supports_prompt_caching: true
supports_function_calling: true
supports_tool_choice: true
mode: chat
chat_inference_params:
temperature: 0.7
top_k: 50
# Model Google Vertex AI (Gemini) menggunakan anchor model bersama
- model_name: my-gemini-model
<<: *my-base-model
# Model yang kompatibel dengan OpenAI dengan sertifikat CA kustom
- model_name: example-model-mini
openai_compatible:
model: gpt-4o-mini
base_url: https://llm-mock-server.ca-tor.containers.appdomain.cloud
ca_cert_pem: env.CA_CERT
model_info:
exposed: true
max_input_tokens: 131072
input_cost_per_token: 0.00000015
output_cost_per_token: 0.0000006
supports_function_calling: true
supports_tool_choice: true
mode: chat
# Model yang kompatibel dengan OpenAI dengan header tambahan
- model_name: another-example-model-mini
openai_compatible:
model: gpt-4o-mini
base_url: https://llm-mock-server.ca-tor.containers.appdomain.cloud
extra_headers:
model_key: env.MODEL_KEY
model_info:
exposed: true
max_input_tokens: 131072
input_cost_per_token: 0.00000015
output_cost_per_token: 0.0000006
supports_function_calling: true
supports_tool_choice: true
mode: chatSecret (config.yaml)
bob:
modelGateway:
secrets:
BOB_AZURE_API_KEY: someapikeyvalue
AWS_ACCESS_KEY: someapikeyvalue
AWS_SECRET_ACCESS_KEY: someapikeyvalue
GEMINI_CREDENTIALS: <base64_vertex_credentials>
CA_CERT: <PEM encoded CA cert>
MODEL_KEY: apikeyvaluePerintah instalasi
bobctl install --model-config /tmp/example/model-gateway.yamlMen-deploy konfigurasi
Selama instalasi awal
Berikan jalur ke file konfigurasi model gateway menggunakan flag --model-config saat instalasi:
bobctl install --model-config path/to/model-gateway-config.yaml --accept-licenseJika bobctl install dijalankan tanpa --model-config, Bob diinstal dengan konfigurasi model gateway kosong. Layanan Inference berjalan tetapi tidak memiliki koneksi ke model apa pun untuk inferencing. Gunakan bobctl update-model-config pasca-instalasi untuk menerapkan konfigurasi model ke cluster.
Bagaimana kredensial di-deploy ke cluster
File konfigurasi model gateway merujuk kredensial sebagai environment variable (misalnya, env.AWS_ACCESS_KEY, env.BOB_AZURE_API_KEY). Penyedia model yang berbeda memerlukan secret yang berbeda — AWS IAM key untuk Bedrock, API key untuk Azure OpenAI, atau service account JSON untuk Google Gemini.
Selama instalasi, kredensial ini disediakan dalam config.yaml kamu di bawah bob.modelGateway.secrets. CLI bobctl secara otomatis memproses bagian ini dan membuat Kubernetes Secret bernama bob-inference-model-secrets di dalam cluster, memasang kunci sebagai environment variable langsung di dalam container layanan inference gateway.
bob:
modelGateway:
secrets:
# Autentikasi AWS Bedrock
AWS_ACCESS_KEY: "<your-aws-access-key-id>"
AWS_SECRET_ACCESS_KEY: "<your-aws-secret-access-key>"
# Autentikasi Azure OpenAI
BOB_AZURE_API_KEY: "<your-azure-api-key>"
# Autentikasi Google Cloud Vertex AI / Gemini
BOB_GEMINI_CREDENTIALS: "<your-gemini-credentials-json>"
# API key / token endpoint kustom atau autentikasi proxy internal
# RITS_APIKEY: "<your-api-key>"
# Sertifikat CA kustom dalam format PEM untuk endpoint internal self-signed
# CA_CERT: |
# -----BEGIN CERTIFICATE-----
# ...
# -----END CERTIFICATE-----Memperbarui konfigurasi pasca-instalasi (bobctl update-model-config)
Gunakan bobctl update-model-config untuk menerapkan konfigurasi model gateway dan/atau secret ke cluster yang sedang berjalan tanpa perlu menginstal ulang. Ini adalah jalur yang diperlukan jika bobctl install dijalankan tanpa --model-config, dan perintah yang sama digunakan saat mengganti model inferensi inti.
Perintah ini mengelola dua resource cluster yang terpisah:
| Flag | Resource cluster | Sumber |
|---|---|---|
--model-config <file> | ConfigMap bob-inference-model-config | File yang kamu masukkan |
--update-secrets | Secret bob-inference-model-secrets | bob.modelGateway.secrets di config.yaml |
Setidaknya salah satu dari keduanya harus diberikan — tidak memberikan keduanya akan menghasilkan error.
Prasyarat:
- Kamu harus sudah login ke cluster (
oc login) config.yamlharus ada di sebelahbobctl(salin dariconfig-template.yaml)helm≥ 3.14.0 harus ada di PATH-mu
Penggunaan umum:
# Perbarui hanya file konfigurasi model
bobctl update-model-config --model-config ./my-model-config.yaml
# Perbarui hanya secret (kunci diambil dari config.yaml)
bobctl update-model-config --update-secrets
# Perbarui keduanya sekaligus
bobctl update-model-config --model-config ./my-model-config.yaml --update-secrets
# Pratinjau apa yang akan diterapkan tanpa menyentuh cluster
bobctl update-model-config --model-config ./my-model-config.yaml --update-secrets --dry-runSemua flag:
| Flag | Default | Deskripsi |
|---|---|---|
--model-config <file> | Jalur ke file konfigurasi model untuk dimasukkan ke dalam ConfigMap | |
--update-secrets | Menerapkan bob.modelGateway.secrets dari config.yaml ke dalam Secret | |
--output-config <file> | model-gateway-config.yaml | Tempat menulis manifes ConfigMap yang di-render |
--output-secret <file> | model-gateway-secret.yaml | Tempat menulis manifes Secret yang di-render |
--cleanup | false | Hapus file manifes yang di-render setelah menerapkannya |
--dry-run | false | Cetak apa yang akan dijalankan tanpa mengeksekusi perintah oc apa pun |