@@ -9,73 +9,164 @@ The Rapida SDK provides a powerful interface for interacting with Rapida AI serv
99To install the Rapida SDK, use the following command:
1010
1111```
12- go get github.com/rapidaai/rapida-sdk/rapida
12+ go get github.com/rapidaai/rapida-go@v0.0.7
1313```
1414
1515## Quick Start
1616
17- Here's a basic example to get you started with the Rapida SDK:
17+ Here's how to get started with the Rapida SDK:
1818
1919``` go
2020package main
2121
2222import (
2323 " context"
2424 " fmt"
25- " github.com/rapidaai/rapida-sdk /rapida"
25+ " github.com/rapidaai/rapida-go /rapida/connections "
2626)
2727
2828func main () {
29- options := rapida.NewRapidaClientOption ()
30- options.SetRapidaApiKey (" your-api-key-here" )
29+ connectionConfig := connections.DefaultConnectionConfig (
30+ connections.WithSDK (" your-api-key-here" ), // Replace with your SDK API Key
31+ )
3132
32- client , err := rapida.GetClient (options)
33- if err != nil {
34- fmt.Printf (" Error creating client: %v \n " , err)
35- return
36- }
33+ client := connectionConfig.CreateClient (context.Background ())
3734
3835 // Use the client to make API calls
39- // ...
36+ fmt. Println ( " Client initialized successfully! " , client)
4037}
4138```
4239
43- ## Key Components
40+ ## Authentication
41+
42+ You can configure the Rapida SDK to authenticate using your ** API Key** or ** Personal Token** :
43+
44+ ### Authenticating with API Key
45+
46+ ``` go
47+ import (
48+ " os"
49+ " github.com/rapidaai/rapida-go/rapida/connections"
50+ )
51+
52+ connectionConfig := connections.DefaultConnectionConfig (
53+ connections.WithSDK (
54+ os.Getenv (" RAPIDA_API_KEY" ), // API Key from environment variables
55+ ),
56+ )
57+ ```
4458
45- ### RapidaClientOption
59+ ### Authenticating with Personal Token
4660
47- The ` RapidaClientOption ` struct allows you to configure the SDK client. Key methods include:
61+ ``` go
62+ import (
63+ " os"
64+ " github.com/rapidaai/rapida-go/rapida/connections"
65+ )
4866
49- - ` NewRapidaClientOption() ` : Creates a new option struct with default values.
50- - ` NewRapidaClientOptionWithParams() ` : Creates a new option struct with custom parameters.
51- - ` SetRapidaApiKey() ` : Sets the API key for authentication.
52- - ` SetRapidaEndpointUrl() ` : Sets the endpoint URL.
53- - ` SetRapidaAssistantUrl() ` : Sets the assistant URL.
54- - ` SetRapidaEnvironment() ` : Sets the environment (e.g., production, staging).
55- - ` SetRapidaRegion() ` : Sets the region for API calls.
56- - ` SetSecure() ` : Sets whether to use a secure connection.
67+ connectionConfig := connections. DefaultConnectionConfig (
68+ connections. WithPersonalToken (
69+ os. Getenv ( " RAPIDA_AUTHORIZATION_TOKEN " ), // Authorization Token
70+ os. Getenv ( " RAPIDA_AUTH_ID " ), // Authentication ID
71+ os. Getenv ( " RAPIDA_PROJECT_ID " ), // Project ID
72+ ),
73+ )
74+ ```
5775
58- ### Initialize Rapida Client
76+ ## Initializing a Client
5977
60- The ` Client ` interface defines the core functionality for making API calls :
78+ Once the configuration is set, you can initialize the Rapida client. Example :
6179
6280``` go
63- client , _ := rapida.GetClient (rapida_builders.ClientOptionBuilder ().WithApiKey (" {RAPIDA_KEY}" ).Build ())
81+ package main
82+
83+ import (
84+ " context"
85+ " github.com/rapidaai/rapida-go/rapida/connections"
86+ )
87+
88+ func main () {
89+ connectionConfig := connections.DefaultConnectionConfig (
90+ connections.WithSDK (" your-api-key-here" ),
91+ )
92+
93+ client := connectionConfig.CreateClient (context.Background ())
94+
95+ // Client ready for API calls
96+ fmt.Println (" Client initialized successfully!" )
97+ }
6498```
6599
66- ### Calling Rapida endpoint
100+ ## Invoking API Endpoints
67101
68- The ` Client ` interface defines the core functionality for making API calls :
102+ Here’s an example of how to call a specific API endpoint with the initialized client :
69103
70104``` go
105+ package main
106+
107+ import (
108+ " context"
109+ " fmt"
110+ " log"
111+ " github.com/rapidaai/rapida-go/rapida"
112+ " github.com/rapidaai/rapida-go/rapida/builders"
113+ " github.com/rapidaai/rapida-go/rapida/definitions"
114+ )
115+
116+ func main () {
117+ connectionConfig := connections.DefaultConnectionConfig (
118+ connections.WithSDK (" your-api-key-here" ),
119+ )
120+
121+ client := connectionConfig.CreateClient (context.Background ())
122+
123+ endpoint , err := definitions.NewEndpoint (2084859551571509248 , " vrsn_2084859551600869376" )
124+ if err != nil {
125+ log.Fatalf (" Failed to create endpoint: %v " , err)
126+ }
127+
128+ request := builders.InvokeRequestBuilder (endpoint).Build ()
129+ response , err := client.Invoke (request)
130+ if err != nil {
131+ log.Fatalf (" API call failed: %v " , err)
132+ }
133+
134+ data , err := response.GetData ()
135+ if err != nil {
136+ log.Fatalf (" Failed to process response: %v " , err)
137+ }
71138
72- endpoint , _ := rapida_definitions.NewEndpoint (2084859551571509248 , " vrsn_2084859551600869376" )
73- res , _ := client.Invoke (rapida_builders.InvokeRequestBuilder (endpoint).Build ())
74- data , err := res.GetData ()
75- if err == nil {
76- for _ , c := range data {
77- print (c.ToText ())
139+ for _ , record := range data {
140+ fmt.Println (record.ToText ())
78141 }
79142}
143+ ```
144+
145+ ## Configuration Options
146+
147+ The ` DefaultConnectionConfig ` accepts multiple options for configuring the SDK. Key options include:
148+
149+ - ` WithSDK(apiKey string) ` : Sets the API key for authentication.
150+ - ` WithPersonalToken(authToken, authId, projectId string) ` : Configures the connection for personal tokens.
151+ - ` WithEndpointURL(url string) ` : Overrides the default API endpoint URL.
152+ - ` WithTimeout(timeout time.Duration) ` : Sets the timeout for API requests.
153+
154+ ## Compatibility
80155
156+ This SDK requires ** Go 1.18 or later** . Ensure your system meets this requirement:
157+
158+ ``` bash
159+ go version
160+ ```
161+
162+ To upgrade or specify a version, use the following command:
163+
164+ ``` bash
165+ go get github.com/rapidaai/rapida-go@v0.0.7
81166```
167+
168+ ---
169+
170+ ## Conclusion
171+
172+ The Rapida SDK provides everything necessary to integrate seamlessly with Rapida AI services, offering flexible configuration and authentication options. With the examples provided, you should be able to get started quickly and make advanced API calls as needed.
0 commit comments