> ## Documentation Index
> Fetch the complete documentation index at: https://docs.geekai.co/llms.txt
> Use this file to discover all available pages before exploring further.

# ID Card Recognition

<Note>
  Note: If the `model` value is not passed, the free `glm-4v-flash` is used by default. You can also choose other image recognition models supported by GeekAI in the [Model Marketplace](https://geekai.dev/models). The cost is based on the model price (API) displayed in the list.
</Note>

### cURL Request Example

```bash theme={null}
curl --location 'https://geekai.dev/api/v1/idcard/recognize' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {YOUR_GEEKAI_API_KEY}' \
--data '{
    "image": "https://example.com/idcard.jpg"
}'
```


## OpenAPI

````yaml openapi.yaml POST /idcard/recognize
openapi: 3.1.0
info:
  title: 极客智坊 API文档
  description: 极客智坊 API 消息接口规范文档
  version: 1.0.0
servers:
  - url: https://geekai.co/api/v1
    description: 国内代理入口
  - url: https://geekai.dev/api/v1
    description: 海外代理入口
security:
  - bearerAuth: []
  - apiKeyAuth: []
paths:
  /idcard/recognize:
    post:
      tags:
        - OCR
      summary: 身份证识别接口
      description: 识别身份证图片中的文字信息，支持正反面识别。
      operationId: recognizeIdCard
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - image
              properties:
                image:
                  type: string
                  description: 支持图片URL或Base64编码图片，支持主流图片格式，如png/jpg/jpeg等
                  example: ''
                model:
                  type: string
                  description: 支持图片识别的模型，不传默认是免费的glm-4v-flash
                  example: glm-4v-flash
      responses:
        '200':
          description: 成功响应
          content:
            application/json:
              schema:
                type: object
                properties:
                  name:
                    type: string
                    description: 姓名
                    example: 张三
                  sex:
                    type: string
                    description: 性别
                    enum:
                      - 男
                      - 女
                    example: 男
                  nation:
                    type: string
                    description: 民族
                    example: 汉
                  birth:
                    type: string
                    description: 出生日期
                    format: date
                    example: 2025年2月10日
                  address:
                    type: string
                    description: 住址
                    example: 浙江省杭州市上城区XX小区XX幢元XX室
                  id:
                    type: string
                    description: 身份证号码
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - example:
                      code: invalid_image
                      message: 图片格式不支持或无法访问
        '401':
          $ref: '#/components/responses/Unauthorized'
        '413':
          description: 图片过大
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - example:
                      code: image_too_large
                      message: 图片大小超过5MB限制
        '500':
          $ref: '#/components/responses/StandardError'
components:
  schemas:
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: 错误代码
          example: invalid_request
        message:
          type: string
          description: 错误信息描述
          example: 请求参数不合法
  responses:
    Unauthorized:
      description: 未授权
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: unauthorized
              message:
                type: string
                example: Invalid API key or token
    StandardError:
      description: 标准错误响应
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: API认证token
    apiKeyAuth:
      type: apiKey
      in: header
      name: GeekAI-API-Key
      description: API密钥认证

````