1515 * modelName: string,
1616 * apiKey?: string|null,
1717 * baseURL?: string|null,
18+ * headers?: array<string,string>|null,
1819 * provider?: null|Provider|value-of<Provider>,
1920 * }
2021 */
@@ -41,6 +42,14 @@ final class ModelConfig implements BaseModel
4142 #[Optional]
4243 public ?string $ baseURL ;
4344
45+ /**
46+ * Custom headers sent with every request to the model provider.
47+ *
48+ * @var array<string,string>|null $headers
49+ */
50+ #[Optional(map: 'string ' )]
51+ public ?array $ headers ;
52+
4453 /**
4554 * AI provider for the model (or provide a baseURL endpoint instead).
4655 *
@@ -73,12 +82,14 @@ public function __construct()
7382 *
7483 * You must use named parameters to construct any parameters with a default value.
7584 *
85+ * @param array<string,string>|null $headers
7686 * @param Provider|value-of<Provider>|null $provider
7787 */
7888 public static function with (
7989 string $ modelName ,
8090 ?string $ apiKey = null ,
8191 ?string $ baseURL = null ,
92+ ?array $ headers = null ,
8293 Provider |string |null $ provider = null ,
8394 ): self {
8495 $ self = new self ;
@@ -87,6 +98,7 @@ public static function with(
8798
8899 null !== $ apiKey && $ self ['apiKey ' ] = $ apiKey ;
89100 null !== $ baseURL && $ self ['baseURL ' ] = $ baseURL ;
101+ null !== $ headers && $ self ['headers ' ] = $ headers ;
90102 null !== $ provider && $ self ['provider ' ] = $ provider ;
91103
92104 return $ self ;
@@ -125,6 +137,19 @@ public function withBaseURL(string $baseURL): self
125137 return $ self ;
126138 }
127139
140+ /**
141+ * Custom headers sent with every request to the model provider.
142+ *
143+ * @param array<string,string> $headers
144+ */
145+ public function withHeaders (array $ headers ): self
146+ {
147+ $ self = clone $ this ;
148+ $ self ['headers ' ] = $ headers ;
149+
150+ return $ self ;
151+ }
152+
128153 /**
129154 * AI provider for the model (or provide a baseURL endpoint instead).
130155 *
0 commit comments