Skip to content

Commit 37529f1

Browse files
committed
fix: restructure
1 parent b05d4b8 commit 37529f1

1 file changed

Lines changed: 36 additions & 27 deletions

File tree

python/README.md

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,36 @@ The AICA API client module provides simple functions for interacting with the AI
88

99
Refer to https://docs.aica.tech for more information about the AICA System.
1010

11+
## Authentication with an API key
12+
13+
For connecting to AICA Core v4.3.0 and later, an API key is required for authentication.
14+
15+
API keys can be generated in AICA Studio with configurable access scopes. Note that available scopes are limited to
16+
those of the currently logged-in user. A generated API key is only shown once and should be kept secret. For example, it
17+
may be exported as an environment variable. The following example key is shown for demonstrative purposes only:
18+
19+
```shell
20+
export AICA_API_KEY=64ce9e8f-aa46-4ba7-814f-f169c01c957e.RwoH6A1Ti5poNKSizoWrcBEYzh7AkB0kpMq1TR59t6os
21+
```
22+
23+
The API key must then be provided to the constructor with the `api_key` keyword argument:
24+
25+
```python
26+
import os
27+
from aica_api.client import AICA
28+
29+
AICA_API_KEY = os.getenv('AICA_API_KEY')
30+
aica = AICA(api_key=AICA_API_KEY)
31+
```
32+
1133
## Basic usage
1234

1335
```python
36+
import os
1437
from aica_api.client import AICA
1538

16-
aica = AICA()
39+
AICA_API_KEY = os.getenv('AICA_API_KEY')
40+
aica = AICA(api_key=AICA_API_KEY)
1741

1842
if aica.check():
1943
print(f"Connected to AICA Core version {aica.core_version()}")
@@ -57,35 +81,16 @@ conflict with reserved ports. Use the "Open in browser" button from Launcher to
5781
the port from the url.
5882

5983
```python
84+
import os
6085
from aica_api.client import AICA
6186

87+
AICA_API_KEY = os.getenv('AICA_API_KEY')
88+
6289
# connect to a non-default port on the local network
63-
aica = AICA(url='http://localhost:55005/api')
90+
aica = AICA(url='http://localhost:55005/api', api_key=AICA_API_KEY)
6491

6592
# or connect to a different host address entirely
66-
aica = AICA(url='http://192.168.0.1:55005/api')
67-
```
68-
69-
## Authentication with an API key
70-
71-
For connecting to AICA Core v4.3.0 and later, an API key is required for authentication.
72-
73-
API keys can be generated in AICA Studio with configurable access scopes. Note that available scopes are limited to
74-
those of the currently logged-in user. A generated API key is only shown once and should be kept secret. For example, it
75-
may be exported as an environment variable. The following example key is shown for demonstrative purposes only:
76-
77-
```shell
78-
export AICA_API_KEY=64ce9e8f-aa46-4ba7-814f-f169c01c957e.RwoH6A1Ti5poNKSizoWrcBEYzh7AkB0kpMq1TR59t6os
79-
```
80-
81-
The API key can then be provided to the constructor with the `api_key` keyword argument:
82-
83-
```python
84-
import os
85-
from aica_api.client import AICA
86-
87-
AICA_API_KEY = os.getenv('AICA_API_KEY')
88-
aica = AICA(api_key=AICA_API_KEY)
93+
aica = AICA(url='http://192.168.0.1:55005/api', api_key=AICA_API_KEY)
8994
```
9095

9196
## Compatibility table
@@ -138,9 +143,11 @@ AICA Core versions `v5` and later change some endpoints paths, methods and paylo
138143
Recent client versions include a `check()` method to assess the client version and API compatibility.
139144

140145
```python3
146+
import os
141147
from aica_api.client import AICA
142148

143-
aica = AICA()
149+
AICA_API_KEY = os.getenv('AICA_API_KEY')
150+
aica = AICA(api_key=AICA_API_KEY)
144151

145152
# check compatability between the client version and API version
146153
if aica.check():
@@ -152,9 +159,11 @@ else:
152159
The latest client versions also include the following functions to check the configuration details manually.
153160

154161
```python3
162+
import os
155163
from aica_api.client import AICA
156164

157-
aica = AICA()
165+
AICA_API_KEY = os.getenv('AICA_API_KEY')
166+
aica = AICA(api_key=AICA_API_KEY)
158167

159168
# get the current version of this client
160169
print(aica.client_version())

0 commit comments

Comments
 (0)