# SDKs

GLAIR Vision SDKs let you make server-side HTTP requests from your server to GLAIR Vision API endpoints. They handle authentication and boilerplate so you can get started in just a few lines of code.

{% hint style="info" %}
The SDK is under active development. Some APIs may require direct HTTP requests to the endpoint rather than using SDK methods.
{% endhint %}

## Node.js SDK

Requires **Node.js v18** or higher. Full details on [NPM](https://www.npmjs.com/package/@glair/vision).

```bash
npm install @glair/vision
```

```javascript
import { Vision } from '@glair/vision';

const vision = new Vision({
  apiKey: 'api-key',
  username: 'username',
  password: 'password',
});

// Accepts file path, base64 string, or Blob/File object
await vision.ocr.ktp({ image: '/path/to/image/KTP.jpg' });
```

### Supported Image Inputs

The `image` parameter accepts:

* **File path** — A string path to a local file.
* **Base64** — A base64-encoded string, with or without a `data:image/...;base64,` prefix.
* **Blob / File** — A `Blob` or `File` object (useful for web form uploads).

### Override Base URL

```javascript
const vision = new Vision({
  baseUrl: 'https://api.vision.glair.ai', // default; override for staging
  apiKey: 'api-key',
  username: 'username',
  password: 'password',
});
```

***

## Java SDK

Requires **Java 8** or higher. Full details on Maven.

```groovy
// build.gradle
implementation 'ai.glair:vision-java-sdk:VERSION'
```

```java
import glair.vision.Vision;
import glair.vision.model.VisionSettings;

VisionSettings settings = new VisionSettings.Builder()
  .username("username")
  .password("password")
  .apiKey("api-key")
  .build();

Vision vision = new Vision(settings);

try {
  KtpParam param = new KtpParam("/path/to/image.jpg");
  String response = vision.ocr().ktp(param);
  System.out.println(response);
} catch (Exception e) {
  System.out.println(e.getMessage());
}
```

### Configuration Options

| Option       | Default                       | Description          |
| ------------ | ----------------------------- | -------------------- |
| `apiKey`     | `default-api-key`             | Your API Key         |
| `username`   | `default-username`            | Your username        |
| `password`   | `default-password`            | Your password        |
| `baseUrl`    | `https://api.vision.glair.ai` | Base URL for the API |
| `apiVersion` | `v1`                          | API version to use   |

***

## Go SDK

Requires **Go 1.18** or higher. Full details on [GitHub](https://github.com/glair-ai/glair-vision-go).

```bash
go get -u github.com/glair-ai/glair-vision-go
```

```go
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "log"
    "os"

    "github.com/glair-ai/glair-vision-go"
    "github.com/glair-ai/glair-vision-go/client"
)

func main() {
    ctx := context.Background()

    config := glair.NewConfig("username", "password", "api-key")
    client := client.New(config)

    file, _ := os.Open("path/to/image.jpg")

    result, err := client.Ocr.KTP(ctx, glair.OCRInput{Image: file})
    if err != nil {
        log.Fatalln(err.Error())
    }

    jsonResponse, _ := json.MarshalIndent(result, "", "  ")
    fmt.Println(string(jsonResponse))
}
```

### Configuration Options

| Option       | Default                          | Description                   |
| ------------ | -------------------------------- | ----------------------------- |
| `BaseUrl`    | `https://api.vision.glair.ai`    | Base URL for GLAIR Vision API |
| `ApiVersion` | `v1`                             | API version to use            |
| `Client`     | Default Go HTTP client           | HTTP client for requests      |
| `Logger`     | `LeveledLogger` with `LevelNone` | Logger instance               |

***

## Android SDK

{% hint style="warning" %}
This SDK is currently in beta and subject to significant changes. Contact <hi@glair.ai> or your company representative to access it.
{% endhint %}

**Requirements:** Android 7 (API Level 24) or above. Requires the `VisionSDK.zip` file provided by GLAIR.

**Installation:**

1. Extract `VisionSDK.zip` to `~/.m2/repository`.
2. Add `mavenLocal()` to `settings.gradle.kts`:

```kotlin
dependencyResolutionManagement {
  repositories {
    mavenLocal()
  }
}
```

3. Add the dependency to `build.gradle.kts`:

```kotlin
dependencies {
  implementation("ai.glair:vision-android-sdk:VERSION")
}
```

**Basic configuration:**

```kotlin
import ai.glair.vision.model.VisionConfiguration

val config = VisionConfiguration.builder<KtpCustomization>()
  .apiKey("apiKey")
  .username("username")
  .password("password")
  .build()
```

For interactive UI components (KTP capture, liveness flows), see the full Android SDK guide at <https://docs.glair.ai/vision/sdks>.

***

## iOS SDK

{% hint style="warning" %}
This SDK is currently in beta and subject to significant changes. Contact <hi@glair.ai> or your company representative to access it.
{% endhint %}

**Requirements:** iOS 13 or higher. Requires the `VisionSDK.xcframework` file provided by GLAIR.

**Installation:**

1. Drag `VisionSDK.xcframework` into the Frameworks group in your Xcode project.
2. Set it to **Embed & Sign** in the Frameworks, Libraries, and Embedded Content section.

**Configuration:**

```swift
import VisionApp

let config = VisionConfig(
    apiKey: "apiKey",
    username: "username",
    password: "password"
)

VisionApp.sharedInstance.configure(config)
```

For full iOS SDK usage including KTP capture and liveness views, see <https://docs.glair.ai/vision/sdks>.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gdplabs.gitbook.io/sdk/computer-vision/sdks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
