---
updatedAt: 2026-03-26T15:01:29.000Z
agentTools:
  projectIndex: https://developers.laratranslate.com/llms.txt
---

# Detect language

## Detect

Detect the source language of a sentence or of a set of sentences. It's possible to specify a hint and a pass list to refine the result of the detection.

### Request

```python
res = lara.detect('Hello, how are you?',
                     hint='en',
                     passlist=['en', 'fr', 'it']
                     )

print(res.language)
```
```typescript
const res  = await lara.detect('Hello, how are you?', 'en', ['en', 'fr', 'it');
                                                             
console.log(res.language);

```
```java
DetectResult res = lara.detect("Hello, how are you?", "en", {"en", "fr", "it"});
```
```php
$res = $lara->detect('Hello, how are you?', 'en', array('en', 'fr', 'it');
```
```go
res, _ := lara.Detect("Hello, how are you?", "en", []string{"en", "fr", "it})

fmt.Println(*res.Language.String)
```
```kotlin
val res: DetectResult = lara.detect(
    "Hello, how are you?",
    "en",
    {"en", "fr", "it"}
)
```
```csharp
var res = await lara.Detect(
    "Hello, how are you?", "en", new[] { "en", "fr", "it" });
```
```swift
let res = try await lara.detect(text: "Hello, how are you?", hint: "en", passlist: ["en", "fr", "it"])
```

Here follows the basic fields for the `detect` method:

<Table align={["left","left","left","left","left"]}>
  <thead>
    <tr>
      <th>
        Field
      </th>

      <th>
        Type
      </th>

      <th>
        Required
      </th>

      <th>
        Default
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        text
      </td>

      <td>
        String | <br />
        String[]
      </td>

      <td>
        Yes
      </td>

      <td>
        * <br />
      </td>

      <td>
        The text to be detected. This can be a single string or a list (up to 128 elements) of strings.
      </td>
    </tr>

    <tr>
      <td>
        hint
      </td>

      <td>
        String
      </td>

      <td>
        No
      </td>

      <td>
        * <br />
      </td>

      <td>
        An hint for the source language code (e.g., "en-US" for English).
      </td>
    </tr>

    <tr>
      <td>
        passlist
      </td>

      <td>
        String[]
      </td>

      <td>
        No
      </td>

      <td>
        * <br />
      </td>

      <td>
        A list of language codes. If specified, the result will be restricted to this set.
      </td>
    </tr>
  </tbody>
</Table>

The result of the `detect` method is an object containing:

| Field         | Type      | Description                                       |
| :------------ | :-------- | :------------------------------------------------ |
| language      | String    | The detected language                             |
| content\_type | String    | The detected content type                         |
| predictions   | String\[] | List of languages detected, with confidence score |

### Response

```python
{
  language: 'en',
  contentType: 'text/plain',
  predictions: [ { language: 'en', confidence: 0.999946 } ]
}
```

## Billing

More details are available in the [pricing page](https://developers.laratranslate.com/docs/pricing-page)