i have an issue with google gemini live api: ``` ...
# ask-ai
a
i have an issue with google gemini live api:
Copy code
File "/agent-livekit/.venv/lib/python3.13/site-packages/livekit/plugins/google/utils.py", line 47, in to_fnc_ctx
    json_schema=types.JSONSchema.model_validate(
        info.raw_schema.get("parameters", {})
    )
  File "/agent-livekit/.venv/lib/python3.13/site-packages/pydantic/main.py", line 705, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        obj, strict=strict, from_attributes=from_attributes, context=context, by_alias=by_alias, by_name=by_name
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
pydantic_core._pydantic_core.ValidationError: 1 validation error for JSONSchema
$schema
  Extra inputs are not permitted [type=extra_forbidden, input_value='<http://json-schema.org/draft-07/schema#>', input_type=str]
    For further information visit <https://errors.pydantic.dev/2.11/v/extra_forbidden>
t
Thanks for reaching out, Sebastián. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I see the Pydantic validation error coming from
livekit/plugins/google/utils.py
where
types.JSONSchema.model_validate(...)
rejects an extra
$schema
field (
"<http://json-schema.org/draft-07/schema#>"
). I’ll help you get it fixed. What’s happening • The plugin is validating the tool/function
parameters
as a
JSONSchema
Pydantic model that forbids extra fields. • Your schema (or a generated schema) contains the top-level
$schema
keyword. Standard JSON Schema allows this metadata, but the
JSONSchema
model used here does not accept extra keys like
$schema
. What you can do (quick fixes) • Remove the
$schema
property from the
parameters
object before it hits
types.JSONSchema.model_validate
. ◦ If you provide the schema manually, omit
$schema
. Example:
Copy code
raw_schema = {
      "type": "object",
      "properties": {
        "location": {"type": "string"}
      },
      "required": ["location"]
    }
• If the schema is generated automatically (from function annotations or another tool), sanitize it in code by popping `$schema`: ◦ Example (conceptual):
Copy code
params = info.raw_schema.get("parameters", {})
    params.pop("$schema", None)
    types.JSONSchema.model_validate(params)
• Ensure your function tool definitions use supported fields only:
type
,
properties
,
required
, etc., and avoid adding meta-schema keys. Diagnostic questions (so I can give a targeted fix) 1. Are you defining the function/tool schema manually, or is it generated from Python type hints / another library? 2. Can you share the
info.raw_schema
(or at least the
parameters
portion) that’s causing this validation error? 3. Which version of
livekit-plugins-google
(or LiveKit packages) are you running? There may be updates that handle this case differently. Additional suggestions • If this schema is produced by an external generator, adjust that generator to avoid emitting
$schema
in the
parameters
block. • If you prefer, I can provide a small wrapper snippet you can drop in before validation to strip
$schema
and any other unsupported top-level keys. If you share the
parameters
JSON or tell me whether the schema is manual vs generated and your package version, I’ll give the exact code snippet to apply. Sources: Tool definition and use | LiveKit Documentation | Google Gemini LLM plugin guide | LiveKit Documentation
a
im running 1.3 since im with agents 1.3 version, and i have this log too:
Copy code
01:00:57.507 INFO   google_genai.types                                                                                        
                                           Note: Conversion of fields that are not included in the JSONSchema class are ignored.  
                                           Json Schema is now supported natively by both Vertex AI and Gemini API. Users          
                                           are recommended to pass/receive Json Schema directly to/from the API. For example:     
                                           1. the counter part of GenerateContentConfig.response_schema is                        
                                              GenerateContentConfig.response_json_schema, which accepts [JSON                     
                                             Schema](<https://json-schema.org/>)                                                    
                                           2. the counter part of FunctionDeclaration.parameters is                               
                                              FunctionDeclaration.parameters_json_schema, which accepts [JSON                     
                                              Schema](<https://json-schema.org/>)                                                   
                                           3. the counter part of FunctionDeclaration.response is                                 
                                              FunctionDeclaration.response_json_schema, which accepts [JSON                       
                                              Schema](<https://json-schema.org/>)
t
Thanks — this is very helpful. I see three useful facts from what you shared: • You’re running agents / LiveKit 1.3. • The validation error is raised because
types.JSONSchema
forbids extra fields and your schema includes a top-level
$schema
value (`http://json-schema.org/draft-07/schema#`). • The google_genai library log notes that JSON Schema is supported natively and that newer fields use `*_json_schema
(for example
FunctionDeclaration.parameters_json_schema`) to accept full JSON Schema, while older fields may still use the restricted model. What you can do next (ordered from least to most invasive) 1) Quick patch: strip
$schema
before validation • If you can change the code path just before
types.JSONSchema.model_validate(...)
, remove
$schema
from
parameters
. This is the simplest immediate fix:
Copy code
params = info.raw_schema.get("parameters", {}) or {}
params.pop("$schema", None)
types.JSONSchema.model_validate(params)
• This preserves the rest of the schema while avoiding the Pydantic extra-field error. 2) Use the JSON-Schema-specific fields where supported • The log shows the google_genai library supports passing full JSON Schema via `parameters_json_schema
(and related
*_json_schema
fields). If your tool/function definitions or generator can emit into
parameters_json_schema` instead of
parameters
, the library will accept standard JSON Schema (including
$schema
) without stripping. • Check where
info.raw_schema
is produced and prefer populating
parameters_json_schema
with the full JSON Schema object. 3) Update schema generation (recommended for long-term) • If a schema generator you control is adding
$schema
at top level, change it to stop emitting
$schema
into the
parameters
block (or emit into
parameters_json_schema
if the consumer supports it). • Ensure generated schema only includes the supported properties if you must keep using the old
parameters
field (e.g.,
type
,
properties
,
required
). Questions so I can give the exact snippet or next step 1. Is
info.raw_schema
produced by your own code (manual) or by an automatic generator (e.g., from type hints or another library)? 2. Can you paste the
parameters
object (or
parameters_json_schema
) that’s present in
info.raw_schema
? A trimmed version is fine. 3. Are you able to modify the LiveKit plugin code in your environment (to add a sanitizer), or do you prefer changing the schema generation upstream? If you want, I can provide: • A small wrapper function you can drop into the plugin to safely strip
$schema
and any other unsupported top-level keys before validation. • A sample change to emit into
parameters_json_schema
instead of
parameters
, if you share how your tool definitions are created. Tell me which option you prefer and share the
parameters
JSON (if convenient), and I’ll give the exact code to apply.