@@ -19,7 +19,7 @@ class Config
1919 /**
2020 * @var string Current API version
2121 */
22- private string $ apiVersion = 'v1 ' ;
22+ private string $ apiVersion = '' ;
2323
2424 /**
2525 * @var array Default configuration options
@@ -29,7 +29,6 @@ class Config
2929 'connect_timeout ' => 10 ,
3030 'max_retries ' => 3 ,
3131 'retry_delay ' => 1000 ,
32- 'base_url ' => 'https://api.x.ai ' ,
3332 'debug ' => false ,
3433 'stream_buffer_size ' => 1024 ,
3534 ];
@@ -39,21 +38,26 @@ class Config
3938 */
4039 private array $ config ;
4140
41+ private function loadConfig (): array
42+ {
43+ return include __DIR__ . '/config/grok.php ' ;
44+ }
45+
4246 /**
4347 * Config constructor.
4448 *
45- * @param array $options Custom configuration options
49+ * @param array $options
4650 */
4751 public function __construct (array $ options = [])
4852 {
49- $ this ->config = array_merge ($ this ->defaults , $ options );
53+ $ this ->config = array_merge ($ this ->defaults , $ this -> loadConfig (), $ options );
5054 }
5155
5256 /**
5357 * Get a configuration value.
5458 *
55- * @param string $key Configuration key
56- * @param mixed|null $default Default value if key doesn't exist
59+ * @param string $key
60+ * @param mixed|null $default
5761 * @return mixed
5862 */
5963 public function get (string $ key , mixed $ default = null ): mixed
@@ -64,8 +68,8 @@ public function get(string $key, mixed $default = null): mixed
6468 /**
6569 * Set a configuration value.
6670 *
67- * @param string $key Configuration key
68- * @param mixed $value Configuration value
71+ * @param string $key
72+ * @param mixed $value
6973 * @return void
7074 */
7175 public function set (string $ key , mixed $ value ): void
@@ -150,6 +154,17 @@ public function getModelMaxTokens(Model $model): int
150154 return $ model ->contextWindow ();
151155 }
152156
157+ /**
158+ * Sets the base URL in the configuration.
159+ *
160+ * @param string $url
161+ * @return void
162+ */
163+ public function setBaseUrl (string $ url ): void
164+ {
165+ $ this ->config ['base_url ' ] = $ url ;
166+ }
167+
153168 /**
154169 * Get the base URL for API requests.
155170 *
0 commit comments