Skip to content

Commit 17f3736

Browse files
docs: update README to promote server_url over instance
Replace all code examples and documentation to use server_url as the primary configuration parameter. The instance parameter is preserved for backwards compatibility but deprioritized in documentation.
1 parent 20f5ce5 commit 17f3736

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

README.md

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Each namespace has its own authentication requirements and access patterns. Whil
1717
from glean.api_client import Glean
1818
import os
1919

20-
with Glean(api_token="client-token", instance="instance-name") as glean:
20+
with Glean(api_token="client-token", server_url="mycompany-be.glean.com") as glean:
2121
search_response = glean.client.search.query(query="search term")
2222

2323
print(search_response)
@@ -26,7 +26,7 @@ with Glean(api_token="client-token", instance="instance-name") as glean:
2626
from glean.api_client import Glean, models
2727
import os
2828

29-
with Glean(api_token="indexing-token", instance="instance-name") as glean:
29+
with Glean(api_token="indexing-token", server_url="mycompany-be.glean.com") as glean:
3030
document_response = glean.indexing.documents.index(
3131
document=models.Document(
3232
id="doc-123",
@@ -744,14 +744,34 @@ By default, an API error will raise a errors.GleanError exception, which has the
744744
<!-- Start Server Selection [server] -->
745745
## Server Selection
746746

747-
### Server Variables
747+
### Server URL
748748

749-
The default server `https://{instance}-be.glean.com` contains variables and is set to `https://instance-name-be.glean.com` by default. To override default values, the following parameters are available when initializing the SDK client instance:
749+
The recommended way to configure the Glean API server is to pass `server_url` when initializing the SDK client:
750+
751+
```python
752+
from glean.api_client import Glean
753+
754+
glean = Glean(
755+
api_token="your-api-token",
756+
server_url="mycompany-be.glean.com",
757+
)
758+
```
759+
760+
The SDK accepts schemeless URLs (e.g., `"mycompany-be.glean.com"`); the `https://` prefix is added automatically.
761+
762+
You can also configure the server URL via the `GLEAN_SERVER_URL` environment variable.
763+
764+
### Server Variables (backwards compatible)
765+
766+
For backwards compatibility, the SDK also supports the `instance` parameter, which constructs the server URL using the pattern `https://{instance}-be.glean.com`:
750767

751768
| Variable | Parameter | Default | Description |
752769
| ---------- | --------------- | ----------------- | ------------------------------------------------------------------------------------------------------ |
753770
| `instance` | `instance: str` | `"instance-name"` | The instance name (typically the email domain without the TLD) that determines the deployment backend. |
754771

772+
> [!NOTE]
773+
> The `server_url` parameter is preferred over `instance`. If both are provided, `server_url` takes precedence.
774+
755775
#### Example
756776

757777
```python
@@ -761,8 +781,7 @@ import os
761781

762782

763783
with Glean(
764-
server_idx=0,
765-
instance="instance-name",
784+
server_url="mycompany-be.glean.com",
766785
api_token=os.getenv("GLEAN_API_TOKEN", ""),
767786
) as glean:
768787

@@ -989,7 +1008,7 @@ from glean.api_client import Glean
9891008

9901009
glean = Glean(
9911010
api_token=os.environ.get("GLEAN_API_TOKEN", ""),
992-
instance=os.environ.get("GLEAN_INSTANCE", ""),
1011+
server_url="mycompany-be.glean.com",
9931012
)
9941013
```
9951014

@@ -1002,7 +1021,7 @@ from glean.api_client import Glean
10021021

10031022
glean = Glean(
10041023
api_token=os.environ.get("GLEAN_API_TOKEN", ""),
1005-
instance=os.environ.get("GLEAN_INSTANCE", ""),
1024+
server_url="mycompany-be.glean.com",
10061025
exclude_deprecated_after="2026-10-15",
10071026
include_experimental=True,
10081027
)

0 commit comments

Comments
 (0)